[clang] [clang-tools-extra] [llvm] [clang] WIP: Improved Context Declaration tracking (PR #107942)

Matheus Izvekov via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 10 10:58:01 PDT 2024


================
@@ -254,6 +254,33 @@ class CXXBaseSpecifier {
   TypeSourceInfo *getTypeSourceInfo() const { return BaseTypeInfo; }
 };
 
+class ContextDeclOrSentinel {
+  uintptr_t Pointer;
+
+public:
+  ContextDeclOrSentinel(Decl *Pointer) : Pointer(uintptr_t(Pointer)) {}
+  explicit ContextDeclOrSentinel(unsigned TemplateDepth)
+      : Pointer(TemplateDepth << 1 | 1) {}
----------------
mizvekov wrote:

Yeah, I wouldn't expect this value to be too large in practical applications, although for some reason we do currently support very large values here.

But with a PointerInt pair this would become too limited. And we don't need to hold both at the same time, it would be redundant as otherwise having a pointer to the declaration would provide the template depth.

This would be more like using a PointerUnion with a pair of pointers, where you are storing an arbitrary integer instead in one of those.

https://github.com/llvm/llvm-project/pull/107942


More information about the cfe-commits mailing list