[PATCH] D155335: This fixes an issue with 245d10b7a2c12ec25e7b5860a38c61991543a739, where on slightly older versions of clang, we get the below error and several others similar.

Sterling Augustine via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 14 13:21:49 PDT 2023


saugustine created this revision.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
saugustine requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In file included from .../clang/lib/AST/Interp/Source.h:17:
In file included from .../llvm/include/llvm/ADT/PointerUnion.h:19:
In file included from .../llvm/include/llvm/ADT/PointerIntPair.h:18:
.../llvm/include/llvm/Support/PointerLikeTypeTraits.h:61:28: error: invalid application of 'alignof' to an incomplete type 'clang::Decl'

  61 |       detail::ConstantLog2<alignof(T)>::value;
     |                            ^~~~~~~~~~

.../llvm/include/llvm/Support/PointerLikeTypeTraits.h:101:56: note: in instantiation of static data member 'llvm::PointerLikeTypeTraits<clang::Decl *>::NumLowBitsAvailable' requested here

  101 |   static constexpr int NumLowBitsAvailable = NonConst::NumLowBitsAvailable;
      |                                                        ^

.../llvm/include/llvm/ADT/PointerUnion.h:38:54: note: in instantiation of static data member 'llvm::PointerLikeTypeTraits<const clang::Decl *>::NumLowBitsAvailable' requested here

  38 |     return std::min<int>({PointerLikeTypeTraits<Ts>::NumLowBitsAvailable...});
     |                                                      ^

.../llvm/include/llvm/ADT/PointerUnion.h:52:48: note: in instantiation of function template specialization 'llvm::pointer_union_detail::lowBitsAvailable<const clang::Decl *, const clang::Stmt *>' requested here

  52 |     static constexpr int NumLowBitsAvailable = lowBitsAvailable<PTs...>();
     |                                                ^

.../llvm/include/llvm/ADT/PointerIntPair.h:169:28: note: in instantiation of static data member 'llvm::pointer_union_detail::PointerUnionUIntTraits<const clang::Decl *, const clang::Stmt *>::NumLowBitsAvailable' requested here

  169 |   static_assert(PtrTraits::NumLowBitsAvailable <
      |                            ^

.../llvm/include/llvm/ADT/PointerIntPair.h:111:13: note: in instantiation of template class 'llvm::PointerIntPairInfo<void *, 1, llvm::pointer_union_detail::PointerUnionUIntTraits<const clang::Decl *, const clang::Stmt *>>' requested here

  111 |     Value = Info::updateInt(Info::updatePointer(0, PtrVal),
      |             ^

.../llvm/include/llvm/ADT/PointerIntPair.h:89:5: note: in instantiation of member function 'llvm::PointerIntPair<void *, 1, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const clang::Decl *, const clang::Stmt *>>::setPointerAndInt' requested here

  89 |     setPointerAndInt(PtrVal, IntVal);
     |     ^

.../llvm/include/llvm/ADT/PointerUnion.h:77:16: note: in instantiation of member function 'llvm::PointerIntPair<void *, 1, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const clang::Decl *, const clang::Stmt *>>::PointerIntPair' requested here

  77 |         : Base(ValTy(const_cast<void *>(
     |                ^

.../clang/lib/AST/Interp/Source.h:76:31: note: in instantiation of member function 'llvm::pointer_union_detail::PointerUnionMembers<llvm::PointerUnion<const clang::Decl *, const clang::Stmt *>, llvm::PointerIntPair<void *, 1, int, llvm::pointer_union_detail::PointerUnionUIntTraits<const clang::Decl *, const clang::Stmt *>>, 1, const clang::Stmt *>::PointerUnionMembers' requested here

  76 |   SourceInfo(const Stmt *E) : Source(E) {}
     |                               ^

.../clang/lib/AST/Interp/Source.h:22:7: note: forward declaration of 'clang::Decl'

  22 | class Decl;
     |       ^


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D155335

Files:
  clang/lib/AST/Interp/Source.h


Index: clang/lib/AST/Interp/Source.h
===================================================================
--- clang/lib/AST/Interp/Source.h
+++ clang/lib/AST/Interp/Source.h
@@ -14,17 +14,13 @@
 #define LLVM_CLANG_AST_INTERP_SOURCE_H
 
 #include "PrimType.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Stmt.h"
 #include "llvm/ADT/PointerUnion.h"
 #include "llvm/Support/Endian.h"
 
 namespace clang {
 
-class Decl;
-class Stmt;
-class SourceLocation;
-class Expr;
-class SourceRange;
-
 namespace interp {
 class Function;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155335.540549.patch
Type: text/x-patch
Size: 532 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230714/cbaebef1/attachment.bin>


More information about the cfe-commits mailing list