Index: clang/test/CodeGenCXX/debug-info-user-def.cpp =================================================================== --- clang/test/CodeGenCXX/debug-info-user-def.cpp (revision 165971) +++ clang/test/CodeGenCXX/debug-info-user-def.cpp (working copy) @@ -1,14 +1,23 @@ // RUN: %clang_cc1 -emit-llvm -g -triple x86_64-apple-darwin -std=c++11 %s -o - | FileCheck %s class A { + virtual void foo(); // Force a nontrivial artificial constructor. }; template class B { T t; }; -A a; -B b; +// Need to instantiate the ctors and prove the debug info is not there. +int main() { + A a; + B b; + return 0; +} -// Check that no subprograms are emitted into debug info. -// CHECK-NOT: [ DW_TAG_subprogram ] +// We should see subprogram entries for main() and foo() only. +// CHECK-NOT: DW_TAG_subprogram +// CHECK: DW_TAG_subprogram {{.*}} [main] +// CHECK-NOT: DW_TAG_subprogram +// CHECK: DW_TAG_subprogram {{.*}} [foo] +// CHECK-NOT: DW_TAG_subprogram Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp (revision 165971) +++ clang/lib/CodeGen/CodeGenFunction.cpp (working copy) @@ -493,7 +493,9 @@ const FunctionDecl *FD = cast(GD.getDecl()); // Check if we should generate debug info for this function. - if (CGM.getModuleDebugInfo() && !FD->hasAttr()) + const CXXMethodDecl *MD = dyn_cast(FD); + if (CGM.getModuleDebugInfo() && !FD->hasAttr() && + (!MD || MD->isUserProvided())) DebugInfo = CGM.getModuleDebugInfo(); FunctionArgList Args;