aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.h
diff options
context:
space:
mode:
authorChris B <chris.bieneman@me.com>2025-09-07 16:05:37 -0500
committerGitHub <noreply@github.com>2025-09-07 16:05:37 -0500
commit799d3466fa97e24082cb036e71a7a92f72597b4e (patch)
tree510834c86a7ad95ce0dffa1984531743d332a63d /clang/lib/CodeGen/CodeGenModule.h
parentc4d927ce09780ffed87c2f34c48d71c1abe42bac (diff)
downloadllvm-799d3466fa97e24082cb036e71a7a92f72597b4e.zip
llvm-799d3466fa97e24082cb036e71a7a92f72597b4e.tar.gz
llvm-799d3466fa97e24082cb036e71a7a92f72597b4e.tar.bz2
[NFC] Change const char* to StringRef (#154179)
This API takes a const char* with a default nullptr value and immdiately passes it down to an API taking a StringRef. All of the places this is called from are either using compile time string literals, the default argument, or string objects that have known length. Discarding the length known from a calling API to just have to strlen it to call the next layer down that requires a StringRef is a bit silly, so this change updates CodeGenModule::GetAddrOfConstantCString to use StringRef instead of const char* for the GlobalName parameter. It might be worth also replacing the first parameter with an llvm ADT type that avoids allocation, but that change would have wider impact so we should consider it separately.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.h')
-rw-r--r--clang/lib/CodeGen/CodeGenModule.h5
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index b4b3a17..f62350fd 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1186,9 +1186,8 @@ public:
///
/// \param GlobalName If provided, the name to use for the global (if one is
/// created).
- ConstantAddress
- GetAddrOfConstantCString(const std::string &Str,
- const char *GlobalName = nullptr);
+ ConstantAddress GetAddrOfConstantCString(const std::string &Str,
+ StringRef GlobalName = ".str");
/// Returns a pointer to a constant global variable for the given file-scope
/// compound literal expression.