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

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 06:15:38 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:

I'm not complaining about the 'set' method, just that the concern is that it is uninitialized.  I'm saying, why not just initialize it to nullptr?  Or am I misunderstanding the concern.

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


More information about the cfe-commits mailing list