diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 1ec9464e8ad5..bc715f4d6d23 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -2432,7 +2432,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, // If VD is an anonymous union then Storage represents value for // all union fields. const RecordDecl *RD = cast(RT->getDecl()); - if (RD->isUnion()) { + if (RD->isUnion() && RD->isAnonymousStructOrUnion()) { for (RecordDecl::field_iterator I = RD->field_begin(), E = RD->field_end(); I != E; ++I) { @@ -2456,8 +2456,8 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, unsigned Tag, DBuilder.insertDeclare(Storage, D, Builder.GetInsertBlock()); Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } + return; } - return; } // Create the descriptor for the variable. diff --git a/clang/test/CodeGenCXX/debug-info-method.cpp b/clang/test/CodeGenCXX/debug-info-method.cpp index 74e44d107280..8923d5f7e801 100644 --- a/clang/test/CodeGenCXX/debug-info-method.cpp +++ b/clang/test/CodeGenCXX/debug-info-method.cpp @@ -1,12 +1,19 @@ -// RUN: %clang_cc1 -emit-llvm -g %s -o - | FileCheck %s -// CHECK: metadata !"_ZN1A3fooEi", {{.*}}, i32 258 +// RUN: %clang_cc1 -emit-llvm -std=c++11 -g %s -o - | FileCheck %s +// CHECK: metadata !"_ZN1A3fooEiS_3$_0", {{.*}}, i32 258 // CHECK: ""{{.*}}DW_TAG_arg_variable +// CHECK: ""{{.*}}DW_TAG_arg_variable +// CHECK: ""{{.*}}DW_TAG_arg_variable +union { + int a; + float b; +} u; + class A { protected: - void foo(int); + void foo(int, A, decltype(u)); }; -void A::foo(int) { +void A::foo(int, A, decltype(u)) { } A a;