Author: StoeckOverflow
Date: 2026-08-12T14:03:33+01:00
New Revision: 77bebf4a1c406602901cdd20fda8e75b177b83f3

URL: 
https://github.com/llvm/llvm-project/commit/77bebf4a1c406602901cdd20fda8e75b177b83f3
DIFF: 
https://github.com/llvm/llvm-project/commit/77bebf4a1c406602901cdd20fda8e75b177b83f3.diff

LOG: [NFC][AST] Make nullability attributed-type construction const (#215756)

Make the nullability-specific `ASTContext::getAttributedType` overload
`const` and remove a now-unneeded `const_cast` from array-decay
handling.

This addresses feedback from
https://github.com/llvm/llvm-project/pull/215266#discussion_r3751285430.

Reviewers: @j-hui @Xazax-hun @egorzhdan

Added: 
    

Modified: 
    clang/include/clang/AST/ASTContext.h
    clang/lib/AST/ASTContext.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 42c9aa0fcf73b..884c16cffbe75 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1997,7 +1997,7 @@ class ASTContext : public RefCountedBase<ASTContext> {
                              QualType equivalentType) const;
 
   QualType getAttributedType(NullabilityKind nullability, QualType 
modifiedType,
-                             QualType equivalentType);
+                             QualType equivalentType) const;
 
   QualType getBTFTagAttributedType(const BTFTypeTagAttr *BTFAttr,
                                    QualType Wrapped) const;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 47028c616e45c..0131ab60e09e9 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5808,7 +5808,7 @@ QualType ASTContext::getAttributedType(const Attr *attr, 
QualType modifiedType,
 
 QualType ASTContext::getAttributedType(NullabilityKind nullability,
                                        QualType modifiedType,
-                                       QualType equivalentType) {
+                                       QualType equivalentType) const {
   switch (nullability) {
   case NullabilityKind::NonNull:
     return getAttributedType(attr::TypeNonNull, modifiedType, equivalentType);
@@ -8208,8 +8208,7 @@ QualType ASTContext::getArrayDecayedType(QualType Ty) 
const {
 
   // int x[_Nullable] -> int * _Nullable
   if (auto Nullability = Ty->getNullability()) {
-    Result = const_cast<ASTContext *>(this)->getAttributedType(*Nullability,
-                                                               Result, Result);
+    Result = getAttributedType(*Nullability, Result, Result);
   }
   return Result;
 }


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to