Skip to content

[llvm] Drop "const" from "const ArrayRef" (NFC) #138818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

kazutakahirata
Copy link
Contributor

No description provided.

@llvmbot
Copy link
Member

llvmbot commented May 7, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-tablegen

Author: Kazu Hirata (kazutakahirata)

Changes

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

4 Files Affected:

  • (modified) llvm/include/llvm/MC/MCPseudoProbe.h (+1-1)
  • (modified) llvm/include/llvm/Transforms/IPO/Attributor.h (+1-2)
  • (modified) llvm/lib/Transforms/IPO/Attributor.cpp (+1-1)
  • (modified) llvm/utils/TableGen/Common/CodeGenTarget.h (+1-1)
diff --git a/llvm/include/llvm/MC/MCPseudoProbe.h b/llvm/include/llvm/MC/MCPseudoProbe.h
index fd1f055789544..dc14038a03acb 100644
--- a/llvm/include/llvm/MC/MCPseudoProbe.h
+++ b/llvm/include/llvm/MC/MCPseudoProbe.h
@@ -510,7 +510,7 @@ class MCPseudoProbeDecoder {
     return iterator_range(It->second);
   }
 
-  const ArrayRef<MCDecodedPseudoProbeInlineTree> getInlineTreeVec() const {
+  ArrayRef<MCDecodedPseudoProbeInlineTree> getInlineTreeVec() const {
     return InlineTreeVec;
   }
 
diff --git a/llvm/include/llvm/Transforms/IPO/Attributor.h b/llvm/include/llvm/Transforms/IPO/Attributor.h
index f82e169da00e3..0ac5e7e3cc368 100644
--- a/llvm/include/llvm/Transforms/IPO/Attributor.h
+++ b/llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1343,8 +1343,7 @@ struct InformationCache {
 
   /// Return all functions that might be called indirectly, only valid for
   /// closed world modules (see isClosedWorldModule).
-  const ArrayRef<Function *>
-  getIndirectlyCallableFunctions(Attributor &A) const;
+  ArrayRef<Function *> getIndirectlyCallableFunctions(Attributor &A) const;
 
   /// Return the flat address space if the associated target has.
   std::optional<unsigned> getFlatAddressSpace() const;
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 40881fd3ceac8..e432f0cb7d897 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -3285,7 +3285,7 @@ InformationCache::FunctionInfo::~FunctionInfo() {
     It.getSecond()->~InstructionVectorTy();
 }
 
-const ArrayRef<Function *>
+ArrayRef<Function *>
 InformationCache::getIndirectlyCallableFunctions(Attributor &A) const {
   assert(A.isClosedWorldModule() && "Cannot see all indirect callees!");
   return IndirectlyCallableFunctions;
diff --git a/llvm/utils/TableGen/Common/CodeGenTarget.h b/llvm/utils/TableGen/Common/CodeGenTarget.h
index 682cc4e2bc9c6..da2f3e060591a 100644
--- a/llvm/utils/TableGen/Common/CodeGenTarget.h
+++ b/llvm/utils/TableGen/Common/CodeGenTarget.h
@@ -252,7 +252,7 @@ class ComplexPattern {
   const Record *getValueType() const { return Ty; }
   unsigned getNumOperands() const { return NumOperands; }
   const std::string &getSelectFunc() const { return SelectFunc; }
-  const ArrayRef<const Record *> getRootNodes() const { return RootNodes; }
+  ArrayRef<const Record *> getRootNodes() const { return RootNodes; }
   bool hasProperty(enum SDNP Prop) const { return Properties & (1 << Prop); }
   unsigned getComplexity() const { return Complexity; }
   bool wantsRoot() const { return WantsRoot; }

Copy link
Contributor

@jayfoad jayfoad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but this is not specific to ArrayRef, it is just a special case of const return type: https://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html

@kazutakahirata
Copy link
Contributor Author

LGTM but this is not specific to ArrayRef, it is just a special case of const return type: https://clang.llvm.org/extra/clang-tidy/checks/readability/const-return-type.html

Thanks for the review! Yes, I've in fact generated this patch (and its friends) with clang-tidy and been splitting it for easier reviews. The entire result of readability-const-return-type would be too big for one PR (even just for llvm/), often with function declaration changes and definition changes spread apart.

@kazutakahirata kazutakahirata merged commit 806a79a into llvm:main May 7, 2025
14 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_clang_tidy_readability-const-return-type_llvm_ArrayRef branch May 7, 2025 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants