[llvm] [SPIRV] Use StringRef instead of std::string (NFC) (PR #138408)
via llvm-commits
llvm-commits at lists.llvm.org
Sat May 3 08:31:02 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
We can use StringRef for PassPrefix because it is used only with
StringRef::starts_with.
---
Full diff: https://github.com/llvm/llvm-project/pull/138408.diff
1 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
index 78c0d252cb834..c516be0297e66 100644
--- a/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVBuiltins.cpp
@@ -184,11 +184,11 @@ namespace SPIRV {
/// Parses the name part of the demangled builtin call.
std::string lookupBuiltinNameHelper(StringRef DemangledCall,
FPDecorationId *DecorationId) {
- const static std::string PassPrefix = "(anonymous namespace)::";
+ StringRef PassPrefix = "(anonymous namespace)::";
std::string BuiltinName;
// Itanium Demangler result may have "(anonymous namespace)::" prefix
- if (DemangledCall.starts_with(PassPrefix.c_str()))
- BuiltinName = DemangledCall.substr(PassPrefix.length());
+ if (DemangledCall.starts_with(PassPrefix))
+ BuiltinName = DemangledCall.substr(PassPrefix.size());
else
BuiltinName = DemangledCall;
// Extract the builtin function name and types of arguments from the call
``````````
</details>
https://github.com/llvm/llvm-project/pull/138408
More information about the llvm-commits
mailing list