forked from OSchip/llvm-project
Fix crash on missing header in -rewrite-includes.
llvm-svn: 158459
This commit is contained in:
parent
619117a31d
commit
76cae518cf
|
@ -250,7 +250,8 @@ bool InclusionRewriter::Process(FileID FileId,
|
||||||
{
|
{
|
||||||
bool Invalid;
|
bool Invalid;
|
||||||
const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid);
|
const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid);
|
||||||
assert(!Invalid && "Invalid FileID while trying to rewrite includes");
|
if (Invalid) // invalid inclusion
|
||||||
|
return true;
|
||||||
const char *FileName = FromFile.getBufferIdentifier();
|
const char *FileName = FromFile.getBufferIdentifier();
|
||||||
Lexer RawLex(FileId, &FromFile, PP.getSourceManager(), PP.getLangOpts());
|
Lexer RawLex(FileId, &FromFile, PP.getSourceManager(), PP.getLangOpts());
|
||||||
RawLex.SetCommentRetentionState(false);
|
RawLex.SetCommentRetentionState(false);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck -strict-whitespace %s
|
||||||
|
|
||||||
|
#include "foobar.h" // expected-error {{'foobar.h' file not found}}
|
||||||
|
// CHECK: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
|
||||||
|
// CHECK-NEXT: {{^}}#include "foobar.h"
|
||||||
|
// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
|
||||||
|
// CHECK-NEXT: {{^}}# 4 "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/Frontend/rewrite-includes-missing.c" 2{{$}}
|
Loading…
Reference in New Issue