Skip to content

[clang][PCH] Don't try to create standalone debug-info for types marked nodebug #123253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/ObjectFilePCHContainerWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ class PCHContainerGenerator : public ASTConsumer {
if (!TD->isCompleteDefinition())
return true;

if (D->hasAttr<NoDebugAttr>())
return true;

QualType QualTy = Ctx.getTypeDeclType(D);
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
Expand Down
14 changes: 14 additions & 0 deletions clang/test/Modules/gmodules-nodebug.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// REQUIRES: asserts

// RUN: %clang_cc1 -std=c++23 -x c++-header -emit-pch -fmodule-format=obj \
// RUN: -o %t.pch %s \
// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll
// RUN: cat %t-pch.ll | FileCheck %s

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget the REQUIRE: assertions! (because of -debug-only)

template<class...>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just used exactly the template alias that was crashing in the libc++ case. I suppose it doesn't actually have to be a template

using __void_t [[gnu::nodebug]] = void;

__void_t<> func() {}

// CHECK: !DICompileUnit
// CHECK-NOT: __void_t
Loading