summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2014-03-21 21:01:58 +0000
committerAdrian Prantl <aprantl@apple.com>2014-03-21 21:01:58 +0000
commitbebb89359ac252f6a175f930d4ffebfd43d938da (patch)
treed381f1f633f5997b648d29467115fde5f7ed3a01
parentae29f7a5ec459e3e555bce27098d3393198602f8 (diff)
downloadbcm5719-llvm-bebb89359ac252f6a175f930d4ffebfd43d938da.tar.gz
bcm5719-llvm-bebb89359ac252f6a175f930d4ffebfd43d938da.zip
CGDebugInfo: At the end of EmitFunctionStart, Initialize PrevLoc to the
location that the next call emitLocation() would default to. Otherwise setLocation() may wrongly believe that the current source file didn't change, when in fact it did. llvm-svn: 204517
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp5
-rw-r--r--clang/test/CodeGenCXX/linetable-fnbegin.cpp24
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index cfc94430bdf..1a3089a14b2 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2577,9 +2577,12 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, QualType FnType,
if (HasDecl)
DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP)));
- // Push function on region stack.
+ // Push the function onto the lexical block stack.
llvm::MDNode *SPN = SP;
LexicalBlockStack.push_back(SPN);
+ // Initialize PrevLoc to the location of the function header.
+ PrevLoc = Loc;
+
if (HasDecl)
RegionMap[D] = llvm::WeakVH(SP);
}
diff --git a/clang/test/CodeGenCXX/linetable-fnbegin.cpp b/clang/test/CodeGenCXX/linetable-fnbegin.cpp
new file mode 100644
index 00000000000..8f8e4c9c789
--- /dev/null
+++ b/clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s
+// Test that the line table info for Foo<T>::bar() is pointing to the
+// right header file.
+// CHECK: define{{.*}} @_ZN3FooIiE3barEv
+// CHECK-NOT: define
+// CHECK: ret {{.*}}, !dbg ![[DBG:.*]]
+// CHECK: ![[HPP:.*]] = metadata !{metadata !"./template.hpp",
+// CHECK:![[BLOCK:.*]] = metadata !{{{.*}}, metadata ![[HPP]], {{.*}}} ; [ DW_TAG_lexical_block ]
+// CHECK: [[DBG]] = metadata !{i32 23, i32 0, metadata ![[BLOCK]], null}
+# 1 "./template.h" 1
+template <typename T>
+class Foo {
+public:
+ int bar();
+};
+# 21 "./template.hpp"
+template <typename T>
+int Foo<T>::bar() {
+}
+int main (int argc, const char * argv[])
+{
+ Foo<int> f;
+ f.bar();
+}
OpenPOWER on IntegriCloud