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

Alejandro Álvarez Ayllón via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 23 05:26:05 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:

Both inside `Sema` and `ASTReaderDecl` the `NonTypeTemplateParmDecl` is created relatively far from the parsing / deserialization of the constraint.

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


More information about the cfe-commits mailing list