From d1346e2ee2741919a8cc1b1ffe400001e76a6d06 Mon Sep 17 00:00:00 2001 From: Akira Hatanaka Date: Tue, 17 May 2022 09:37:29 -0700 Subject: [PATCH] [gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in DebugTypeVisitor Differential Revision: https://reviews.llvm.org/D125839 --- clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp | 4 ++++ clang/test/Modules/Inputs/gmodules-deduction-guide.h | 11 +++++++++++ clang/test/Modules/gmodules-deduction-guide.cpp | 7 +++++++ 3 files changed, 22 insertions(+) create mode 100644 clang/test/Modules/Inputs/gmodules-deduction-guide.h create mode 100644 clang/test/Modules/gmodules-deduction-guide.cpp diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp index 9fe7e5d..d03e5bd 100644 --- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp +++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp @@ -96,6 +96,10 @@ class PCHContainerGenerator : public ASTConsumer { } bool VisitFunctionDecl(FunctionDecl *D) { + // Skip deduction guides. + if (isa(D)) + return true; + if (isa(D)) // This is not yet supported. Constructing the `this' argument // mandates a CodeGenFunction. diff --git a/clang/test/Modules/Inputs/gmodules-deduction-guide.h b/clang/test/Modules/Inputs/gmodules-deduction-guide.h new file mode 100644 index 0000000..47b5931 --- /dev/null +++ b/clang/test/Modules/Inputs/gmodules-deduction-guide.h @@ -0,0 +1,11 @@ +struct A { +}; + +template +struct S{ + S(const A &); +}; + +S(const A&) -> S; + +typedef decltype(S(A())) Type0; diff --git a/clang/test/Modules/gmodules-deduction-guide.cpp b/clang/test/Modules/gmodules-deduction-guide.cpp new file mode 100644 index 0000000..1017b76 --- /dev/null +++ b/clang/test/Modules/gmodules-deduction-guide.cpp @@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -std=c++2b -x c++-header -emit-pch -fmodule-format=obj -I %S/Inputs \ +// RUN: -o %t.pch %S/Inputs/gmodules-deduction-guide.h \ +// RUN: -mllvm -debug-only=pchcontainer &>%t-pch.ll +// RUN: cat %t-pch.ll | FileCheck %s + +// CHECK: ![[V0:.*]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "Type0",{{.*}}, baseType: ![[V0]]) -- 2.7.4