summaryrefslogtreecommitdiffstats
path: root/clang/test/PCH
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2017-12-04 22:28:45 +0000
committerHans Wennborg <hans@hanshq.net>2017-12-04 22:28:45 +0000
commit1448736e49dbc0978ba6ba8ed2ce66acf23d62f6 (patch)
treeae073d4712db7e1ea65cb991a149d718cd630d49 /clang/test/PCH
parent361d4392cf5425bf560f88895f22df61b273fe4e (diff)
downloadbcm5719-llvm-1448736e49dbc0978ba6ba8ed2ce66acf23d62f6.tar.gz
bcm5719-llvm-1448736e49dbc0978ba6ba8ed2ce66acf23d62f6.zip
Correctly handle line table entries without filenames during AST serialization
The current code would hit an assert in ASTWriter when trying to write out the filename for a line table entry that didn't have any. Fix this by allowing the -1 sentinel value to round-trip through serialization. Differential revision: https://reviews.llvm.org/D40746 llvm-svn: 319707
Diffstat (limited to 'clang/test/PCH')
-rw-r--r--clang/test/PCH/line-directive-nofilename.c9
-rw-r--r--clang/test/PCH/line-directive-nofilename.h5
2 files changed, 14 insertions, 0 deletions
diff --git a/clang/test/PCH/line-directive-nofilename.c b/clang/test/PCH/line-directive-nofilename.c
new file mode 100644
index 00000000000..0d2bcb78c2a
--- /dev/null
+++ b/clang/test/PCH/line-directive-nofilename.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -emit-pch -o %t %S/line-directive-nofilename.h
+// RUN: not %clang_cc1 -include-pch %t -fsyntax-only %s 2>&1 | FileCheck %s
+
+// This causes an "error: redefinition" diagnostic. The notes will have the
+// locations of the declarations from the PCH file.
+double foo, bar;
+
+// CHECK: line-directive-nofilename.h:42:5: note: previous definition is here
+// CHECK: foobar.h:100:5: note: previous definition is here
diff --git a/clang/test/PCH/line-directive-nofilename.h b/clang/test/PCH/line-directive-nofilename.h
new file mode 100644
index 00000000000..2e2d189de3f
--- /dev/null
+++ b/clang/test/PCH/line-directive-nofilename.h
@@ -0,0 +1,5 @@
+#line 42
+int foo; // This should appear as at line-directive-nofilename.h:42
+
+#line 100 "foobar.h"
+int bar; // This should appear as at foobar.h:100
OpenPOWER on IntegriCloud