diff options
author | Nathan James <n.james93@hotmail.co.uk> | 2022-05-09 12:01:45 +0100 |
---|---|---|
committer | Nathan James <n.james93@hotmail.co.uk> | 2022-05-09 12:01:46 +0100 |
commit | 12cb540529e41d12cf27d2e716a384b6692563a8 (patch) | |
tree | 20e80831c1822bc5e540cf63ad947541b6a91fa8 /clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp | |
parent | fc440f27cd50e48e1f9ebe6e56febe2823e59de4 (diff) | |
download | llvm-12cb540529e41d12cf27d2e716a384b6692563a8.zip llvm-12cb540529e41d12cf27d2e716a384b6692563a8.tar.gz llvm-12cb540529e41d12cf27d2e716a384b6692563a8.tar.bz2 |
[clang-tidy][NFC] Replace many instances of std::string where a StringRef would suffice.
There's many instances in clang tidy checks where owning strings are used when we already have a stable string from the options, so using a StringRef makes much more sense.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D124341
Diffstat (limited to 'clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp')
-rw-r--r-- | clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp index 63c6f6b8..c78fd7f 100644 --- a/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp +++ b/clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp @@ -141,7 +141,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { // Add 'override' on inline declarations that don't already have it. if (!HasFinal && !HasOverride) { SourceLocation InsertLoc; - std::string ReplacementText = OverrideSpelling + " "; + std::string ReplacementText = (OverrideSpelling + " ").str(); SourceLocation MethodLoc = Method->getLocation(); for (Token T : Tokens) { @@ -171,7 +171,7 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { // end of the declaration of the function, but prefer to put it on the // same line as the declaration if the beginning brace for the start of // the body falls on the next line. - ReplacementText = " " + OverrideSpelling; + ReplacementText = (" " + OverrideSpelling).str(); auto *LastTokenIter = std::prev(Tokens.end()); // When try statement is used instead of compound statement as // method body - insert override keyword before it. @@ -192,14 +192,14 @@ void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) { InsertLoc = Tokens[Tokens.size() - 2].getLocation(); // Check if we need to insert a space. if ((Tokens[Tokens.size() - 2].getFlags() & Token::LeadingSpace) == 0) - ReplacementText = " " + OverrideSpelling + " "; + ReplacementText = (" " + OverrideSpelling + " ").str(); } else if (getText(Tokens.back(), Sources) == "ABSTRACT") InsertLoc = Tokens.back().getLocation(); } if (!InsertLoc.isValid()) { InsertLoc = FileRange.getEnd(); - ReplacementText = " " + OverrideSpelling; + ReplacementText = (" " + OverrideSpelling).str(); } // If the override macro has been specified just ensure it exists, |