Jac1494 updated this revision to Diff 234273. Jac1494 added a comment. Separate clang patch with test cases .
CHANGES SINCE LAST ACTION https://reviews.llvm.org/D71451/new/ https://reviews.llvm.org/D71451 Files: clang/include/clang/Basic/TargetInfo.h clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGen/debug-info-extern-variable-basic.c clang/test/CodeGen/debug-info-extern-variable-unused.c Index: clang/test/CodeGen/debug-info-extern-variable-unused.c =================================================================== --- /dev/null +++ clang/test/CodeGen/debug-info-extern-variable-unused.c @@ -0,0 +1,10 @@ +// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s + +extern int i; +int foo() { + extern int j; + return 0; +} + +// CHECK-NOT: distinct !DIGlobalVariable(name: "i" +// CHECK-NOT: distinct !DIGlobalVariable(name: "j" Index: clang/test/CodeGen/debug-info-extern-variable-basic.c =================================================================== --- /dev/null +++ clang/test/CodeGen/debug-info-extern-variable-basic.c @@ -0,0 +1,10 @@ +// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s + +extern int i; +int foo() { + extern int j; + return i+j; +} + +// CHECK: distinct !DIGlobalVariable(name: "i" +// CHECK: distinct !DIGlobalVariable(name: "j" Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -4594,6 +4594,8 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (D->hasAttr<NoDebugAttr>()) return; + if (!(DebugKind == clang::codegenoptions::FullDebugInfo)) + return; auto Align = getDeclAlignIfRequired(D, CGM.getContext()); llvm::DIFile *Unit = getOrCreateFile(D->getLocation()); Index: clang/include/clang/Basic/TargetInfo.h =================================================================== --- clang/include/clang/Basic/TargetInfo.h +++ clang/include/clang/Basic/TargetInfo.h @@ -1390,7 +1390,7 @@ virtual void setAuxTarget(const TargetInfo *Aux) {} /// Whether target allows debuginfo types for decl only variables. - virtual bool allowDebugInfoForExternalVar() const { return false; } + virtual bool allowDebugInfoForExternalVar() const { return true; } protected: /// Copy type and layout related info.
Index: clang/test/CodeGen/debug-info-extern-variable-unused.c =================================================================== --- /dev/null +++ clang/test/CodeGen/debug-info-extern-variable-unused.c @@ -0,0 +1,10 @@ +// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s + +extern int i; +int foo() { + extern int j; + return 0; +} + +// CHECK-NOT: distinct !DIGlobalVariable(name: "i" +// CHECK-NOT: distinct !DIGlobalVariable(name: "j" Index: clang/test/CodeGen/debug-info-extern-variable-basic.c =================================================================== --- /dev/null +++ clang/test/CodeGen/debug-info-extern-variable-basic.c @@ -0,0 +1,10 @@ +// RUN: %clang -emit-llvm -S -g -fstandalone-debug %s -o - | FileCheck %s + +extern int i; +int foo() { + extern int j; + return i+j; +} + +// CHECK: distinct !DIGlobalVariable(name: "i" +// CHECK: distinct !DIGlobalVariable(name: "j" Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -4594,6 +4594,8 @@ assert(DebugKind >= codegenoptions::LimitedDebugInfo); if (D->hasAttr<NoDebugAttr>()) return; + if (!(DebugKind == clang::codegenoptions::FullDebugInfo)) + return; auto Align = getDeclAlignIfRequired(D, CGM.getContext()); llvm::DIFile *Unit = getOrCreateFile(D->getLocation()); Index: clang/include/clang/Basic/TargetInfo.h =================================================================== --- clang/include/clang/Basic/TargetInfo.h +++ clang/include/clang/Basic/TargetInfo.h @@ -1390,7 +1390,7 @@ virtual void setAuxTarget(const TargetInfo *Aux) {} /// Whether target allows debuginfo types for decl only variables. - virtual bool allowDebugInfoForExternalVar() const { return false; } + virtual bool allowDebugInfoForExternalVar() const { return true; } protected: /// Copy type and layout related info.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits