summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2013-01-20 01:19:17 +0000
committerDavid Blaikie <dblaikie@gmail.com>2013-01-20 01:19:17 +0000
commitd42917f01c39b5300e844c3ab038547498385279 (patch)
tree3415b7bee6de3abb5cff1e48821ef1bd39084bcd /clang
parenta39a76efbcb2065b92335ddde0ac287748642a86 (diff)
downloadbcm5719-llvm-d42917f01c39b5300e844c3ab038547498385279.tar.gz
bcm5719-llvm-d42917f01c39b5300e844c3ab038547498385279.zip
The last of PR14471: Debug info support for inline in-class initializer for float static members
llvm-svn: 172942
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp12
-rw-r--r--clang/test/CodeGenCXX/debug-info-static-member.cpp8
2 files changed, 12 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 27ccc3b494f..37df4b33ce4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -842,11 +842,15 @@ CollectRecordStaticField(const VarDecl *Var,
unsigned LineNumber = getLineNumber(Var->getLocation());
StringRef VName = Var->getName();
- llvm::ConstantInt *CI = NULL;
+ llvm::Constant *C = NULL;
if (Var->getInit()) {
const APValue *Value = Var->evaluateValue();
- if (Value && Value->isInt())
- CI = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+ if (Value) {
+ if (Value->isInt())
+ C = llvm::ConstantInt::get(CGM.getLLVMContext(), Value->getInt());
+ if (Value->isFloat())
+ C = llvm::ConstantFP::get(CGM.getLLVMContext(), Value->getFloat());
+ }
}
unsigned Flags = 0;
@@ -857,7 +861,7 @@ CollectRecordStaticField(const VarDecl *Var,
Flags |= llvm::DIDescriptor::FlagProtected;
llvm::DIType GV = DBuilder.createStaticMemberType(RecordTy, VName, VUnit,
- LineNumber, VTy, Flags, CI);
+ LineNumber, VTy, Flags, C);
elements.push_back(GV);
StaticDataMemberCache[Var->getCanonicalDecl()] = llvm::WeakVH(GV);
}
diff --git a/clang/test/CodeGenCXX/debug-info-static-member.cpp b/clang/test/CodeGenCXX/debug-info-static-member.cpp
index 42b3f63307e..953db582f87 100644
--- a/clang/test/CodeGenCXX/debug-info-static-member.cpp
+++ b/clang/test/CodeGenCXX/debug-info-static-member.cpp
@@ -5,10 +5,10 @@
class C
{
static int a;
- const static int const_a = 16;
+ const static bool const_a = true;
protected:
static int b;
- const static int const_b = 17;
+ const static float const_b = 3.14;
public:
static int c;
const static int const_c = 18;
@@ -32,9 +32,9 @@ int main()
// CHECK: metadata !"a", {{.*}} @_ZN1C1aE, metadata ![[DECL_A:[0-9]+]]} ; [ DW_TAG_variable ] [a] {{.*}} [def]
// CHECK: ![[DECL_A]] = metadata {{.*}} [ DW_TAG_member ] [a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
-// CHECK: metadata !"const_a", {{.*}} [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
+// CHECK: metadata !"const_a", {{.*}}, i1 true} ; [ DW_TAG_member ] [const_a] [line {{.*}}, size 0, align 0, offset 0] [private] [static]
// CHECK: ![[DECL_B:[0-9]+]] {{.*}} metadata !"b", {{.*}} [ DW_TAG_member ] [b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
-// CHECK: metadata !"const_b", {{.*}} [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
+// CHECK: metadata !"const_b", {{.*}}, float 0x{{.*}}} ; [ DW_TAG_member ] [const_b] [line {{.*}}, size 0, align 0, offset 0] [protected] [static]
// CHECK: ![[DECL_C:[0-9]+]] {{.*}} metadata !"c", {{.*}} [ DW_TAG_member ] [c] [line {{.*}}, size 0, align 0, offset 0] [static]
// CHECK: metadata !"const_c", {{.*}} [ DW_TAG_member ] [const_c] [line {{.*}}, size 0, align 0, offset 0] [static]
// CHECK: metadata !"b", {{.*}} @_ZN1C1bE, metadata ![[DECL_B]]} ; [ DW_TAG_variable ] [b] {{.*}} [def]
OpenPOWER on IntegriCloud