[PATCH] D86624: [clang] Exclude invalid destructors from lookups.

Adam Czachorowski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 08:18:34 PDT 2020


adamcz updated this revision to Diff 287983.
adamcz marked 2 inline comments as done.
adamcz added a comment.

addressed review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D86624/new/

https://reviews.llvm.org/D86624

Files:
  clang/lib/AST/DeclBase.cpp
  clang/test/PCH/cxx-invalid-destructor.cpp
  clang/test/PCH/cxx-invalid-destructor.h


Index: clang/test/PCH/cxx-invalid-destructor.h
===================================================================
--- /dev/null
+++ clang/test/PCH/cxx-invalid-destructor.h
@@ -0,0 +1,7 @@
+struct Base {
+  ~Base();
+};
+
+struct Foo : public Base {
+  ~Base();
+};
Index: clang/test/PCH/cxx-invalid-destructor.cpp
===================================================================
--- /dev/null
+++ clang/test/PCH/cxx-invalid-destructor.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -x c++ -std=c++11 -emit-pch -o %t %S/cxx-invalid-destructor.h -fallow-pch-with-compiler-errors
+// RUN: %clang_cc1 -x c++ -std=c++11 -include-pch %t %S/cxx-invalid-destructor.cpp -fsyntax-only -fno-validate-pch
+
+Foo f;
Index: clang/lib/AST/DeclBase.cpp
===================================================================
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -1487,6 +1487,13 @@
     if (FD->isFunctionTemplateSpecialization())
       return true;
 
+  // Hide destructors that are invalid. There should always be one destructor,
+  // but if it is an invalid decl, another one is created. We need to hide the
+  // invalid one from places that expect exactly one destructor, like the
+  // serialization code.
+  if (isa<CXXDestructorDecl>(D) && D->isInvalidDecl())
+    return true;
+
   return false;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86624.287983.patch
Type: text/x-patch
Size: 1317 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200826/2b7b072a/attachment.bin>


More information about the cfe-commits mailing list