llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Erick Velez (evelez7) <details> <summary>Changes</summary> Change some parameters in DeclarationFragments.h to be passed by const reference. Caught by cppcheck. Fixes #<!-- -->92756 but doesn't address return value `RT` for `getTopLevelRecords`. I'm not sure we'd want a const return of the top records, and returning `RT` by reference makes clang complain about returning a temporary object. --- Full diff: https://github.com/llvm/llvm-project/pull/94820.diff 1 Files Affected: - (modified) clang/include/clang/ExtractAPI/DeclarationFragments.h (+5-4) ``````````diff diff --git a/clang/include/clang/ExtractAPI/DeclarationFragments.h b/clang/include/clang/ExtractAPI/DeclarationFragments.h index 535da90b98284..7dae4e2f8ac1d 100644 --- a/clang/include/clang/ExtractAPI/DeclarationFragments.h +++ b/clang/include/clang/ExtractAPI/DeclarationFragments.h @@ -199,7 +199,8 @@ class DeclarationFragments { return *this; } - DeclarationFragments &replace(std::string NewSpelling, unsigned Position) { + DeclarationFragments &replace(const std::string &NewSpelling, + unsigned Position) { Fragments.at(Position).Spelling = NewSpelling; return *this; } @@ -240,7 +241,7 @@ class DeclarationFragments { class AccessControl { public: - AccessControl(std::string Access) : Access(Access) {} + AccessControl(const std::string &Access) : Access(Access) {} AccessControl() : Access("public") {} const std::string &getAccess() const { return Access; } @@ -262,7 +263,7 @@ class FunctionSignature { std::string Name; DeclarationFragments Fragments; - Parameter(StringRef Name, DeclarationFragments Fragments) + Parameter(StringRef Name, const DeclarationFragments &Fragments) : Name(Name), Fragments(Fragments) {} }; @@ -275,7 +276,7 @@ class FunctionSignature { return *this; } - void setReturnType(DeclarationFragments RT) { ReturnType = RT; } + void setReturnType(const DeclarationFragments &RT) { ReturnType = RT; } /// Determine if the FunctionSignature is empty. /// `````````` </details> https://github.com/llvm/llvm-project/pull/94820 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits