mirror of
				https://github.com/MaskRay/ccls.git
				synced 2025-11-03 22:04:24 +00:00 
			
		
		
		
	Use SM.isWrittenInMainFile; suppress -Werror in preamble
SM.isWrittenInMainFile is to work around preamble bug: spurious err_pp_unterminated_conditional with circular #include
This commit is contained in:
		
							parent
							
								
									6283f7e919
								
							
						
					
					
						commit
						2e16b3c6bb
					
				@ -209,7 +209,7 @@ public:
 | 
				
			|||||||
    if (!L.isValid()) return;
 | 
					    if (!L.isValid()) return;
 | 
				
			||||||
    const SourceManager &SM = Info.getSourceManager();
 | 
					    const SourceManager &SM = Info.getSourceManager();
 | 
				
			||||||
    StringRef Filename = SM.getFilename(Info.getLocation());
 | 
					    StringRef Filename = SM.getFilename(Info.getLocation());
 | 
				
			||||||
    bool concerned = IsConcerned(SM, Info.getLocation());
 | 
					    bool concerned = SM.isWrittenInMainFile(L);
 | 
				
			||||||
    auto fillDiagBase = [&](DiagBase &d) {
 | 
					    auto fillDiagBase = [&](DiagBase &d) {
 | 
				
			||||||
      llvm::SmallString<64> Message;
 | 
					      llvm::SmallString<64> Message;
 | 
				
			||||||
      Info.FormatDiagnostic(Message);
 | 
					      Info.FormatDiagnostic(Message);
 | 
				
			||||||
@ -303,6 +303,11 @@ void BuildPreamble(CompletionSession &session, CompilerInvocation &CI,
 | 
				
			|||||||
  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), Buf.get(), 0);
 | 
					  auto Bounds = ComputePreambleBounds(*CI.getLangOpts(), Buf.get(), 0);
 | 
				
			||||||
  if (OldP && OldP->Preamble.CanReuse(CI, Buf.get(), Bounds, FS.get()))
 | 
					  if (OldP && OldP->Preamble.CanReuse(CI, Buf.get(), Bounds, FS.get()))
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					  // -Werror makes warnings issued as errors, which stops parsing
 | 
				
			||||||
 | 
					  // prematurely because of -ferror-limit=. This also works around the issue
 | 
				
			||||||
 | 
					  // of -Werror + -Wunused-parameter in interaction with SkipFunctionBodies.
 | 
				
			||||||
 | 
					  auto &Ws = CI.getDiagnosticOpts().Warnings;
 | 
				
			||||||
 | 
					  Ws.erase(std::remove(Ws.begin(), Ws.end(), "error"), Ws.end());
 | 
				
			||||||
  CI.getDiagnosticOpts().IgnoreWarnings = false;
 | 
					  CI.getDiagnosticOpts().IgnoreWarnings = false;
 | 
				
			||||||
  CI.getFrontendOpts().SkipFunctionBodies = true;
 | 
					  CI.getFrontendOpts().SkipFunctionBodies = true;
 | 
				
			||||||
  CI.getLangOpts()->CommentOpts.ParseAllComments = g_config->index.comments > 1;
 | 
					  CI.getLangOpts()->CommentOpts.ParseAllComments = g_config->index.comments > 1;
 | 
				
			||||||
 | 
				
			|||||||
@ -707,7 +707,7 @@ public:
 | 
				
			|||||||
      if (!db)
 | 
					      if (!db)
 | 
				
			||||||
        return true;
 | 
					        return true;
 | 
				
			||||||
      param.SeenFile(*FE);
 | 
					      param.SeenFile(*FE);
 | 
				
			||||||
      if (!SM.isInMainFile(R.getBegin()))
 | 
					      if (!SM.isWrittenInMainFile(R.getBegin()))
 | 
				
			||||||
        lid = GetFileLID(db, SM, *FE);
 | 
					        lid = GetFileLID(db, SM, *FE);
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
      db = param.ConsumeFile(*FE);
 | 
					      db = param.ConsumeFile(*FE);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user