llvmorg-github-actions[bot] wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: StoeckOverflow

<details>
<summary>Changes</summary>

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

---
Full diff: https://github.com/llvm/llvm-project/pull/215756.diff


2 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+1-1) 
- (modified) clang/lib/AST/ASTContext.cpp (+2-3) 


``````````diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index 763039e690dec..38c2d282c1a6b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1995,7 +1995,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 02a3f88431f58..5b42194a44549 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5795,7 +5795,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);
@@ -8195,8 +8195,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;
 }

``````````

</details>


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

Reply via email to