Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit bae2b31

Browse files
committed
Fix crash on missing header in -rewrite-includes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158459 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 60ad16b commit bae2b31

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/Rewrite/InclusionRewriter.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ bool InclusionRewriter::Process(FileID FileId,
250250
{
251251
bool Invalid;
252252
const MemoryBuffer &FromFile = *SM.getBuffer(FileId, &Invalid);
253-
assert(!Invalid && "Invalid FileID while trying to rewrite includes");
253+
if (Invalid) // invalid inclusion
254+
return true;
254255
const char *FileName = FromFile.getBufferIdentifier();
255256
Lexer RawLex(FileId, &FromFile, PP.getSourceManager(), PP.getLangOpts());
256257
RawLex.SetCommentRetentionState(false);
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %clang_cc1 -verify -E -frewrite-includes %s -o - | FileCheck -strict-whitespace %s
2+
3+
#include "foobar.h" // expected-error {{'foobar.h' file not found}}
4+
// CHECK: {{^}}#if 0 /* expanded by -frewrite-includes */{{$}}
5+
// CHECK-NEXT: {{^}}#include "foobar.h"
6+
// CHECK-NEXT: {{^}}#endif /* expanded by -frewrite-includes */{{$}}
7+
// CHECK-NEXT: {{^}}# 4 "/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/Frontend/rewrite-includes-missing.c" 2{{$}}

0 commit comments

Comments
 (0)