[clang] f71749c - [clang] Drop explicit conversions of string literals to StringRef (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Thu May 16 22:32:11 PDT 2024
Author: Kazu Hirata
Date: 2024-05-16T22:32:06-07:00
New Revision: f71749c5ef8667e3fc23820e8e94864653ea9ac9
URL: https://github.com/llvm/llvm-project/commit/f71749c5ef8667e3fc23820e8e94864653ea9ac9
DIFF: https://github.com/llvm/llvm-project/commit/f71749c5ef8667e3fc23820e8e94864653ea9ac9.diff
LOG: [clang] Drop explicit conversions of string literals to StringRef (NFC)
We routinely rely on implicit conversions of string literals to
StringRef so that we can use operator==(StringRef, StringRef).
The LHS here are all known to be of StringRef.
Added:
Modified:
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Serialization/ASTWriter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 33f1f466df244..a3b378c42df33 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -177,7 +177,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
return CapabilityExpr();
if (const auto* SLit = dyn_cast<StringLiteral>(AttrExp)) {
- if (SLit->getString() == StringRef("*"))
+ if (SLit->getString() == "*")
// The "*" expr is a universal lock, which essentially turns off
// checks until it is removed from the lockset.
return CapabilityExpr(new (Arena) til::Wildcard(), StringRef("wildcard"),
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 3760a4c917ad7..30776ff537fb5 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -640,7 +640,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
if (const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
if (StrLit->getLength() == 0 ||
- (StrLit->isOrdinary() && StrLit->getString() == StringRef("*"))) {
+ (StrLit->isOrdinary() && StrLit->getString() == "*")) {
// Pass empty strings to the analyzer without warnings.
// Treat "*" as the universal lock.
Args.push_back(ArgExp);
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index 129bc337c8924..dd5d65b2eb20e 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1460,7 +1460,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
(!PP.getHeaderSearchInfo()
.getHeaderSearchOpts()
.ModuleMapFileHomeIsCwd ||
- WritingModule->Directory->getName() != StringRef("."))) {
+ WritingModule->Directory->getName() != ".")) {
// Module directory.
auto Abbrev = std::make_shared<BitCodeAbbrev>();
Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));
More information about the cfe-commits
mailing list