aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorBruno De Fraine <brunodf@synopsys.com>2021-06-29 09:46:27 +0200
committerJeroen Dobbelaere <jeroen.dobbelaere@synopsys.com>2021-06-29 10:26:45 +0200
commit4d8871a898b30f11c905b27954c18d826c0953c9 (patch)
tree4bdec0465f8ad78e6c103f7ce8844895fb2461a1 /clang/lib/CodeGen/CodeGenFunction.cpp
parentb8bac6b33c576dec88add0e6a68e96219e278c8a (diff)
downloadllvm-4d8871a898b30f11c905b27954c18d826c0953c9.zip
llvm-4d8871a898b30f11c905b27954c18d826c0953c9.tar.gz
llvm-4d8871a898b30f11c905b27954c18d826c0953c9.tar.bz2
PR50767: clear non-distinct debuginfo for function with nodebug definition after undecorated declaration
Fix suggested by Yuanfang Chen: Non-distinct debuginfo is attached to the function due to the undecorated declaration. Later, when seeing the function definition and `nodebug` attribute, the non-distinct debuginfo should be cleared. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D104777
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0ca9465..578b8a8 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1304,8 +1304,14 @@ void CodeGenFunction::GenerateCode(GlobalDecl GD, llvm::Function *Fn,
QualType ResTy = BuildFunctionArgList(GD, Args);
// Check if we should generate debug info for this function.
- if (FD->hasAttr<NoDebugAttr>())
- DebugInfo = nullptr; // disable debug info indefinitely for this function
+ if (FD->hasAttr<NoDebugAttr>()) {
+ // Clear non-distinct debug info that was possibly attached to the function
+ // due to an earlier declaration without the nodebug attribute
+ if (Fn)
+ Fn->setSubprogram(nullptr);
+ // Disable debug info indefinitely for this function
+ DebugInfo = nullptr;
+ }
// The function might not have a body if we're generating thunks for a
// function declaration.