diff options
-rw-r--r-- | include/clang/Basic/DiagnosticSerializationKinds.td | 2 | ||||
-rw-r--r-- | lib/Serialization/ASTReader.cpp | 2 | ||||
-rw-r--r-- | test/PCH/badpch-dir.h.gch/.keep | 0 | ||||
-rw-r--r-- | test/PCH/badpch-empty.h.gch | 0 | ||||
-rw-r--r-- | test/PCH/badpch.c | 13 |
5 files changed, 15 insertions, 2 deletions
diff --git a/include/clang/Basic/DiagnosticSerializationKinds.td b/include/clang/Basic/DiagnosticSerializationKinds.td index 6e27f3490f..a440e806d7 100644 --- a/include/clang/Basic/DiagnosticSerializationKinds.td +++ b/include/clang/Basic/DiagnosticSerializationKinds.td @@ -10,7 +10,7 @@ let Component = "Serialization" in { def err_fe_unable_to_read_pch_file : Error< - "unable to read PCH file: '%0'">; + "unable to read PCH file %0: '%1'">; def err_fe_not_a_pch_file : Error< "input is not a PCH file: '%0'">; def err_fe_pch_malformed : Error< diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index f5aa74ea98..da031575a2 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -3001,7 +3001,7 @@ std::string ASTReader::getOriginalSourceFile(const std::string &ASTFileName, OwningPtr<llvm::MemoryBuffer> Buffer; Buffer.reset(FileMgr.getBufferForFile(ASTFileName, &ErrStr)); if (!Buffer) { - Diags.Report(diag::err_fe_unable_to_read_pch_file) << ErrStr; + Diags.Report(diag::err_fe_unable_to_read_pch_file) << ASTFileName << ErrStr; return std::string(); } diff --git a/test/PCH/badpch-dir.h.gch/.keep b/test/PCH/badpch-dir.h.gch/.keep new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/PCH/badpch-dir.h.gch/.keep diff --git a/test/PCH/badpch-empty.h.gch b/test/PCH/badpch-empty.h.gch new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/test/PCH/badpch-empty.h.gch diff --git a/test/PCH/badpch.c b/test/PCH/badpch.c new file mode 100644 index 0000000000..e687ef3246 --- /dev/null +++ b/test/PCH/badpch.c @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -fsyntax-only -include-pch %S/badpch-empty.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-EMPTY %s +// RUN: %clang_cc1 -fsyntax-only -include-pch %S/badpch-dir.h.gch %s 2>&1 | FileCheck -check-prefix=CHECK-DIR %s + +// The purpose of this test is to verify that various invalid PCH files are +// reported as such. + +// PR4568: The messages were much improved since the bug was filed on +// 2009-07-16, though in the case of the PCH being a directory, the error +// message still did not contain the name of the PCH. Also, r149918 which was +// submitted on 2012-02-06 introduced a segfault in the case where the PCH is +// an empty file and clang was built with assertions. +// CHECK-EMPTY: error: input is not a PCH file: '{{.*[/\\]}}badpch-empty.h.gch' +// CHECK-DIR: error: unable to read PCH file {{.*[/\\]}}badpch-dir.h.gch: |