Author: rsmith Date: Thu Jun 1 20:05:44 2017 New Revision: 304506 URL: http://llvm.org/viewvc/llvm-project?rev=304506&view=rev Log: PR32848: There isn't necessarily a FileChanged or FileSkipped for every InclusionDirective callback.
In particular, you don't get one if the inclusion directive encountered an error. Don't assert in that case. Added: cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Modified: cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp?rev=304506&r1=304505&r2=304506&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp (original) +++ cfe/trunk/lib/Frontend/Rewrite/InclusionRewriter.cpp Thu Jun 1 20:05:44 2017 @@ -177,7 +177,9 @@ void InclusionRewriter::FileSkipped(cons /// directives. It does not say whether the file has been included, but it /// provides more information about the directive (hash location instead /// of location inside the included file). It is assumed that the matching -/// FileChanged() or FileSkipped() is called after this. +/// FileChanged() or FileSkipped() is called after this (or neither is +/// called if this #include results in an error or does not textually include +/// anything). void InclusionRewriter::InclusionDirective(SourceLocation HashLoc, const Token &/*IncludeTok*/, StringRef /*FileName*/, @@ -187,9 +189,6 @@ void InclusionRewriter::InclusionDirecti StringRef /*SearchPath*/, StringRef /*RelativePath*/, const Module *Imported) { - assert(LastInclusionLocation.isInvalid() && - "Another inclusion directive was found before the previous one " - "was processed"); if (Imported) { auto P = ModuleIncludes.insert( std::make_pair(HashLoc.getRawEncoding(), Imported)); Added: cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c?rev=304506&view=auto ============================================================================== --- cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c (added) +++ cfe/trunk/test/Frontend/rewrite-includes-filenotfound.c Thu Jun 1 20:05:44 2017 @@ -0,0 +1,6 @@ +// RUN: not %clang_cc1 -E -frewrite-includes %s -o - 2>&1 | FileCheck %s + +#include "this file does not exist.foo" +#include "this file also does not exist.foo" + +CHECK: fatal error: {{.*}} file not found _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits