llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.17k stars 12.03k forks source link

clang/include/clang/Interpreter/Interpreter.h:53: Small performance issue ? #94105

Open dcb314 opened 5 months ago

dcb314 commented 5 months ago

Static analyser cppcheck says:

clang/include/clang/Interpreter/Interpreter.h:53:36: performance: Function parameter 'TT' should be passed by const reference. [passedByValue]

Source code is

void SetTargetTriple(std::string TT) { TargetTriple = TT; }

Maybe better code:

void SetTargetTriple( const std::string & TT ) { TargetTriple = TT; }

jroelofs commented 5 months ago

llvm has its own type for this, which should be used instead of const std::string &, namely llvm::StringRef