[clang] [clang][Sema] Fix initialization of `NonTypeTemplateParmDecl`... (PR #121768)

Alejandro Álvarez Ayllón via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 24 02:37:53 PST 2025


================
@@ -1533,13 +1535,11 @@ class NonTypeTemplateParmDecl final
   /// Return the constraint introduced by the placeholder type of this non-type
   /// template parameter (if any).
   Expr *getPlaceholderTypeConstraint() const {
-    return hasPlaceholderTypeConstraint() ? *getTrailingObjects<Expr *>() :
-        nullptr;
+    return PlaceholderTypeConstraintInitialized ? *getTrailingObjects<Expr *>()
+                                                : nullptr;
   }
 
-  void setPlaceholderTypeConstraint(Expr *E) {
-    *getTrailingObjects<Expr *>() = E;
----------------
alejandro-alvarez-sonarsource wrote:

The flag would allow to discern between "was not initialized" and "was explicitly initialized to null".
Now, I have to admit I do not know if the latter is meaningful for a constrained NTTP.

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


More information about the cfe-commits mailing list