[cfe-commits] r158772 - in /cfe/trunk: include/clang/Basic/DiagnosticSerializationKinds.td lib/Serialization/ASTReader.cpp test/PCH/badpch-dir.h.gch/ test/PCH/badpch-dir.h.gch/.keep test/PCH/badpch-empty.h.gch test/PCH/badpch.c
Kaelyn Uhrain
rikka at google.com
Tue Jun 19 17:36:03 PDT 2012
Author: rikka
Date: Tue Jun 19 19:36:03 2012
New Revision: 158772
URL: http://llvm.org/viewvc/llvm-project?rev=158772&view=rev
Log:
Add the PCH file name to the message about not being able to read the PCH.
Also add a couple of unit tests to check the invalid-PCH error messages
to satisfy PR4568 and for the assertion (introduced in r149918 and fixed
in r158769) that would cause clang to crash when given an empty PCH.
Added:
cfe/trunk/test/PCH/badpch-dir.h.gch/
cfe/trunk/test/PCH/badpch-dir.h.gch/.keep
cfe/trunk/test/PCH/badpch-empty.h.gch
cfe/trunk/test/PCH/badpch.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp
Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=158772&r1=158771&r2=158772&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue Jun 19 19:36:03 2012
@@ -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<
Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=158772&r1=158771&r2=158772&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Jun 19 19:36:03 2012
@@ -3001,7 +3001,7 @@
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();
}
Added: cfe/trunk/test/PCH/badpch-dir.h.gch/.keep
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/badpch-dir.h.gch/.keep?rev=158772&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/PCH/badpch-empty.h.gch
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/badpch-empty.h.gch?rev=158772&view=auto
==============================================================================
(empty)
Added: cfe/trunk/test/PCH/badpch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/badpch.c?rev=158772&view=auto
==============================================================================
--- cfe/trunk/test/PCH/badpch.c (added)
+++ cfe/trunk/test/PCH/badpch.c Tue Jun 19 19:36:03 2012
@@ -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:
More information about the cfe-commits
mailing list