Skip to content

Commit f71749c

Browse files
[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.
1 parent 14030d7 commit f71749c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

clang/lib/Analysis/ThreadSafetyCommon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
177177
return CapabilityExpr();
178178

179179
if (const auto* SLit = dyn_cast<StringLiteral>(AttrExp)) {
180-
if (SLit->getString() == StringRef("*"))
180+
if (SLit->getString() == "*")
181181
// The "*" expr is a universal lock, which essentially turns off
182182
// checks until it is removed from the lockset.
183183
return CapabilityExpr(new (Arena) til::Wildcard(), StringRef("wildcard"),

clang/lib/Sema/SemaDeclAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ static void checkAttrArgsAreCapabilityObjs(Sema &S, Decl *D,
640640

641641
if (const auto *StrLit = dyn_cast<StringLiteral>(ArgExp)) {
642642
if (StrLit->getLength() == 0 ||
643-
(StrLit->isOrdinary() && StrLit->getString() == StringRef("*"))) {
643+
(StrLit->isOrdinary() && StrLit->getString() == "*")) {
644644
// Pass empty strings to the analyzer without warnings.
645645
// Treat "*" as the universal lock.
646646
Args.push_back(ArgExp);

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ void ASTWriter::WriteControlBlock(Preprocessor &PP, ASTContext &Context,
14601460
(!PP.getHeaderSearchInfo()
14611461
.getHeaderSearchOpts()
14621462
.ModuleMapFileHomeIsCwd ||
1463-
WritingModule->Directory->getName() != StringRef("."))) {
1463+
WritingModule->Directory->getName() != ".")) {
14641464
// Module directory.
14651465
auto Abbrev = std::make_shared<BitCodeAbbrev>();
14661466
Abbrev->Add(BitCodeAbbrevOp(MODULE_DIRECTORY));

0 commit comments

Comments
 (0)