Skip to content

Commit c8aed7f

Browse files
committed
[clang][PCH] Don't try to create standalone debug-info for types marked nodebug (llvm#123253)
Fixes one of the crashes uncovered by llvm#118710 `getOrCreateStandaloneType` asserts that a `DIType` was created for the requested type. If the `Decl` was marked `nodebug`, however, we can't generate debug-info for it, so we would previously trigger the assert. For now keep the assertion around and check the `nodebug` at the callsite. (cherry picked from commit 30e276d)
1 parent 206b898 commit c8aed7f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

clang/lib/CodeGen/ObjectFilePCHContainerWriter.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class PCHContainerGenerator : public ASTConsumer {
8484
if (!TD->isCompleteDefinition())
8585
return true;
8686

87+
if (D->hasAttr<NoDebugAttr>())
88+
return true;
89+
8790
QualType QualTy = Ctx.getTypeDeclType(D);
8891
if (!QualTy.isNull() && CanRepresent(QualTy.getTypePtr()))
8992
DI.getOrCreateStandaloneType(QualTy, D->getLocation());
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// REQUIRES: asserts
2+
3+
// RUN: %clang_cc1 -std=c++23 -x c++-header -emit-pch -fmodule-format=obj \
4+
// RUN: -o %t.pch %s \
5+
// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll
6+
// RUN: cat %t-pch.ll | FileCheck %s
7+
8+
template<class...>
9+
using __void_t [[gnu::nodebug]] = void;
10+
11+
__void_t<> func() {}
12+
13+
// CHECK: !DICompileUnit
14+
// CHECK-NOT: __void_t

0 commit comments

Comments
 (0)