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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 21 07:59:42 PST 2025


Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?=,
Alejandro =?utf-8?q?Álvarez_Ayllón?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/121768 at github.com>


================
@@ -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;
----------------
erichkeane wrote:

While I like the assert-safety that we get from the `PlaceholderTypeConstraintInitialized`, I'm not sure it is worth the rigamarole.  Why not just have the `ctor` do `setPlaceholderTypeConstraint`?

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


More information about the cfe-commits mailing list