summaryrefslogtreecommitdiffstats
path: root/lib/Serialization/ASTWriter.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-08 01:08:28 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2012-03-08 01:08:28 +0000
commit29f98b40caabca1ec820d546c5c08206a1d4f520 (patch)
tree10c91c82cf38413ef1dc02df4866fdbeaea2a1a9 /lib/Serialization/ASTWriter.cpp
parentd78ef5b941ce2937228b010e8443f92025f9d683 (diff)
[libclang] Fix a crash when serializing a preprocessing record that contains
an #include entry that did not resolve to header file. Part of rdar://11007039 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@152275 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Serialization/ASTWriter.cpp')
-rw-r--r--lib/Serialization/ASTWriter.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp
index 8b6859cd42..d21dac68de 100644
--- a/lib/Serialization/ASTWriter.cpp
+++ b/lib/Serialization/ASTWriter.cpp
@@ -1832,7 +1832,10 @@ void ASTWriter::WritePreprocessorDetail(PreprocessingRecord &PPRec) {
Record.push_back(static_cast<unsigned>(ID->getKind()));
SmallString<64> Buffer;
Buffer += ID->getFileName();
- Buffer += ID->getFile()->getName();
+ // Check that the FileEntry is not null because it was not resolved and
+ // we create a PCH even with compiler errors.
+ if (ID->getFile())
+ Buffer += ID->getFile()->getName();
Stream.EmitRecordWithBlob(InclusionAbbrev, Record, Buffer);
continue;
}