================
@@ -518,9 +522,29 @@ struct TemplateArgumentLocInfo {
return getTemplate()->EllipsisLoc;
}
+ bool isNull() const { return Pointer.isNull(); }
+
+ bool isTrivial() const { return isa<LocOrPointer>(Pointer); }
+
+ SourceLocation getTrivialLoc() const {
+ assert(isTrivial());
+ auto *P = cast<LocOrPointer>(Pointer);
+ if constexpr (embedLocInPointer)
+ return SourceLocation::getFromRawEncoding(
+ (reinterpret_cast<uintptr_t>(P) >> lowBitsRequired) - 1u);
+ else
+ return *static_cast<SourceLocation *>(P);
+ }
+
private:
- llvm::PointerUnion<TemplateTemplateArgLocInfo *, Expr *, TypeSourceInfo *>
+ static constexpr bool embedLocInPointer = sizeof(void *) >
+ sizeof(SourceLocation);
+ using LocOrPointer =
+ std::conditional_t<embedLocInPointer, void, SourceLocation> *;
+ llvm::PointerUnion<TemplateTemplateArgLocInfo *, Expr *, TypeSourceInfo *,
+ LocOrPointer>
Pointer;
+ static constexpr unsigned lowBitsRequired = 2;
----------------
zyn0217 wrote:
Shouldn't it be 3 to make it 8 byte aligned?
https://github.com/llvm/llvm-project/pull/187352
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits