[llvm] 65647ed - Pass DIEnumerator APInt args by const reference not value.

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 05:20:38 PDT 2020


Author: Simon Pilgrim
Date: 2020-07-01T13:16:07+01:00
New Revision: 65647ed1e5e8a74ef28f19279d329bb49741dcaa

URL: https://github.com/llvm/llvm-project/commit/65647ed1e5e8a74ef28f19279d329bb49741dcaa
DIFF: https://github.com/llvm/llvm-project/commit/65647ed1e5e8a74ef28f19279d329bb49741dcaa.diff

LOG: Pass DIEnumerator APInt args by const reference not value.

Noticed by clang-tidy performance-unnecessary-value-param warning.

Added: 
    

Modified: 
    llvm/include/llvm/IR/DebugInfoMetadata.h
    llvm/lib/IR/DebugInfoMetadata.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 900a4b561cda..7d7cc4de7937 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -359,7 +359,7 @@ class DIEnumerator : public DINode {
   friend class MDNode;
 
   APInt Value;
-  DIEnumerator(LLVMContext &C, StorageType Storage, APInt Value,
+  DIEnumerator(LLVMContext &C, StorageType Storage, const APInt &Value,
                bool IsUnsigned, ArrayRef<Metadata *> Ops)
       : DINode(C, DIEnumeratorKind, Storage, dwarf::DW_TAG_enumerator, Ops),
         Value(Value) {
@@ -371,13 +371,13 @@ class DIEnumerator : public DINode {
                      Ops) {}
   ~DIEnumerator() = default;
 
-  static DIEnumerator *getImpl(LLVMContext &Context, APInt Value,
+  static DIEnumerator *getImpl(LLVMContext &Context, const APInt &Value,
                                bool IsUnsigned, StringRef Name,
                                StorageType Storage, bool ShouldCreate = true) {
     return getImpl(Context, Value, IsUnsigned,
                    getCanonicalMDString(Context, Name), Storage, ShouldCreate);
   }
-  static DIEnumerator *getImpl(LLVMContext &Context, APInt Value,
+  static DIEnumerator *getImpl(LLVMContext &Context, const APInt &Value,
                                bool IsUnsigned, MDString *Name,
                                StorageType Storage, bool ShouldCreate = true);
 

diff  --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index ea90d6842c31..110d94116f10 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -435,7 +435,7 @@ DISubrange::BoundType DISubrange::getStride() const {
   return BoundType();
 }
 
-DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, APInt Value,
+DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, const APInt &Value,
                                     bool IsUnsigned, MDString *Name,
                                     StorageType Storage, bool ShouldCreate) {
   assert(isCanonical(Name) && "Expected canonical MDString");


        


More information about the llvm-commits mailing list