@@ -556,6 +556,10 @@ void *diagnosticMain(void *manager_) {
556
556
std::shared_ptr<PreambleData> preamble = session->getPreamble ();
557
557
IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs =
558
558
preamble ? preamble->stat_cache ->consumer (session->fs ) : session->fs ;
559
+ std::unique_ptr<CompilerInvocation> ci =
560
+ buildCompilerInvocation (task.path , session->file .args , fs);
561
+ if (!ci)
562
+ continue ;
559
563
if (preamble) {
560
564
bool rebuild = false ;
561
565
{
@@ -567,16 +571,25 @@ void *diagnosticMain(void *manager_) {
567
571
rebuild = true ;
568
572
}
569
573
}
574
+ if (!rebuild) {
575
+ std::string content = manager->wfiles ->getContent (task.path );
576
+ auto buf = llvm::MemoryBuffer::getMemBuffer (content);
577
+ #if LLVM_VERSION_MAJOR >= 12 // llvmorg-12-init-11522-g4c55c3b66de
578
+ PreambleBounds bounds =
579
+ ComputePreambleBounds (*ci->getLangOpts (), *buf, 0 );
580
+ #else
581
+ PreambleBounds bounds =
582
+ ComputePreambleBounds (*ci->getLangOpts (), buf.get (), 0 );
583
+ #endif
584
+ if (bounds.Size != preamble->preamble .getBounds ().Size )
585
+ rebuild = true ;
586
+ }
570
587
if (rebuild) {
571
588
manager->preamble_tasks .pushBack ({task.path , nullptr , true }, true );
572
589
continue ;
573
590
}
574
591
}
575
592
576
- std::unique_ptr<CompilerInvocation> ci =
577
- buildCompilerInvocation (task.path , session->file .args , fs);
578
- if (!ci)
579
- continue ;
580
593
// If main file is a header, add -Wno-unused-function
581
594
if (lookupExtension (session->file .filename ).second )
582
595
ci->getDiagnosticOpts ().Warnings .push_back (" no-unused-function" );
0 commit comments