diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-02 01:05:44 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2017-06-02 01:05:44 +0000 |
commit | 4b46f72c7f222e938118ba852ded3060b0a911e4 (patch) | |
tree | aa9baed07619062abf801224e526f68136a0ab36 /clang | |
parent | c38e947e506f152b75df8148e5c1e95eea3fe6b7 (diff) | |
download | bcm5719-llvm-4b46f72c7f222e938118ba852ded3060b0a911e4.tar.gz bcm5719-llvm-4b46f72c7f222e938118ba852ded3060b0a911e4.zip |
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.
llvm-svn: 304506
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Frontend/Rewrite/InclusionRewriter.cpp | 7 | ||||
-rw-r--r-- | clang/test/Frontend/rewrite-includes-filenotfound.c | 6 |
2 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp index d45cbc01df8..3564cebba8a 100644 --- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp +++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp @@ -177,7 +177,9 @@ void InclusionRewriter::FileSkipped(const FileEntry &/*SkippedFile*/, /// 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::InclusionDirective(SourceLocation HashLoc, 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)); diff --git a/clang/test/Frontend/rewrite-includes-filenotfound.c b/clang/test/Frontend/rewrite-includes-filenotfound.c new file mode 100644 index 00000000000..203dbde5451 --- /dev/null +++ b/clang/test/Frontend/rewrite-includes-filenotfound.c @@ -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 |