summaryrefslogtreecommitdiffstats
path: root/clang/test/Frontend/optimization-remark-line-directive.c
diff options
context:
space:
mode:
authorDiego Novillo <dnovillo@google.com>2014-05-08 13:49:54 +0000
committerDiego Novillo <dnovillo@google.com>2014-05-08 13:49:54 +0000
commit6dc9c4814f40a2f4921245cb61aee25b8c418985 (patch)
tree555605d42602f4f86c2554be77b442aea54e85b1 /clang/test/Frontend/optimization-remark-line-directive.c
parente8172d85f9fa6df413ffce29e2fde5b65503d32b (diff)
downloadbcm5719-llvm-6dc9c4814f40a2f4921245cb61aee25b8c418985.tar.gz
bcm5719-llvm-6dc9c4814f40a2f4921245cb61aee25b8c418985.zip
Fix segmentation fault when mixing -Rpass with #line.
Summary: When using #line directives, FileManager::getFile() will return a nil entry. This triggers an assert in translateFileLineCol(). This patch handles nil FileEntry instances by emitting a note that the location could not be translated back to a SourceLocation. I don't really like this solution, but we are translating presumed locations, so some information has already been lost. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D3625 llvm-svn: 208315
Diffstat (limited to 'clang/test/Frontend/optimization-remark-line-directive.c')
-rw-r--r--clang/test/Frontend/optimization-remark-line-directive.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/clang/test/Frontend/optimization-remark-line-directive.c b/clang/test/Frontend/optimization-remark-line-directive.c
new file mode 100644
index 00000000000..b4b1b923249
--- /dev/null
+++ b/clang/test/Frontend/optimization-remark-line-directive.c
@@ -0,0 +1,15 @@
+// This file tests -Rpass diagnostics together with #line
+// directives. We cannot map #line directives back to
+// a SourceLocation.
+
+// RUN: %clang -c %s -Rpass=inline -O0 -S -gmlt -o /dev/null 2> %t.err
+// RUN: FileCheck < %t.err %s --check-prefix=INLINE-INVALID-LOC
+//
+int foo(int x, int y) __attribute__((always_inline));
+int foo(int x, int y) { return x + y; }
+
+#line 1230 "/bad/path/to/original.c"
+int bar(int j) { return foo(j, j - 2); }
+
+// INLINE-INVALID-LOC: {{^remark: foo inlined into bar}}
+// INLINE-INVALID-LOC: note: could not determine the original source location for /bad/path/to/original.c:1230:0
OpenPOWER on IntegriCloud