[clang] 3ba6ace - [gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 6 19:12:58 PDT 2022


Author: Akira Hatanaka
Date: 2022-06-06T19:12:26-07:00
New Revision: 3ba6ace3cc507c241225d6ce92768a9aef417d45

URL: https://github.com/llvm/llvm-project/commit/3ba6ace3cc507c241225d6ce92768a9aef417d45
DIFF: https://github.com/llvm/llvm-project/commit/3ba6ace3cc507c241225d6ce92768a9aef417d45.diff

LOG: [gmodules] Skip CXXDeductionGuideDecls when visiting FunctionDecls in
DebugTypeVisitor

This recommits d1346e2. I've added a line to the test case to enable it
only on assert builds.

Differential Revision: https://reviews.llvm.org/D125839

Added: 
    clang/test/Modules/Inputs/gmodules-deduction-guide.h
    clang/test/Modules/gmodules-deduction-guide.cpp

Modified: 
    clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 9fe7e5d1f5c31..d03e5bd508731 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<CXXDeductionGuideDecl>(D))
+        return true;
+
       if (isa<CXXMethodDecl>(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 0000000000000..47b5931083af1
--- /dev/null
+++ b/clang/test/Modules/Inputs/gmodules-deduction-guide.h
@@ -0,0 +1,11 @@
+struct A {
+};
+
+template <class T>
+struct S{
+  S(const A &);
+};
+
+S(const A&) -> S<A>;
+
+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 0000000000000..6b5a4086b3635
--- /dev/null
+++ b/clang/test/Modules/gmodules-deduction-guide.cpp
@@ -0,0 +1,9 @@
+// REQUIRES: asserts
+
+// 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<A>",
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "Type0",{{.*}}, baseType: ![[V0]])


        


More information about the cfe-commits mailing list