forked from OSchip/llvm-project
Reduce the number of implicit StringRef->std::string conversions by threading StringRef through more APIs.
No functionality change intended. llvm-svn: 260815
This commit is contained in:
parent
2193e23cd7
commit
0772c42385
|
@ -1844,8 +1844,9 @@ inline internal::Matcher<Stmt> sizeOfExpr(
|
|||
/// \code
|
||||
/// namespace a { namespace b { class X; } }
|
||||
/// \endcode
|
||||
inline internal::Matcher<NamedDecl> hasName(const std::string &Name) {
|
||||
return internal::Matcher<NamedDecl>(new internal::HasNameMatcher(Name));
|
||||
inline internal::Matcher<NamedDecl> hasName(std::string Name) {
|
||||
return internal::Matcher<NamedDecl>(
|
||||
new internal::HasNameMatcher(std::move(Name)));
|
||||
}
|
||||
|
||||
/// \brief Matches NamedDecl nodes whose fully qualified names contain
|
||||
|
|
|
@ -640,7 +640,7 @@ private:
|
|||
/// See \c hasName() in ASTMatchers.h for details.
|
||||
class HasNameMatcher : public SingleNodeMatcherInterface<NamedDecl> {
|
||||
public:
|
||||
explicit HasNameMatcher(StringRef Name);
|
||||
explicit HasNameMatcher(std::string Name);
|
||||
|
||||
bool matchesNode(const NamedDecl &Node) const override;
|
||||
|
||||
|
|
|
@ -1364,7 +1364,7 @@ public:
|
|||
/// \param ClientLoadCapabilities The set of client load-failure
|
||||
/// capabilities, represented as a bitset of the enumerators of
|
||||
/// LoadFailureCapabilities.
|
||||
ASTReadResult ReadAST(const std::string &FileName, ModuleKind Type,
|
||||
ASTReadResult ReadAST(StringRef FileName, ModuleKind Type,
|
||||
SourceLocation ImportLoc,
|
||||
unsigned ClientLoadCapabilities);
|
||||
|
||||
|
|
|
@ -774,8 +774,8 @@ public:
|
|||
|
||||
void appendToDesc(StringRef S) {
|
||||
if (!ShortDesc.empty())
|
||||
ShortDesc.append(S);
|
||||
VerboseDesc.append(S);
|
||||
ShortDesc += S;
|
||||
VerboseDesc += S;
|
||||
}
|
||||
|
||||
void resetPath() {
|
||||
|
|
|
@ -293,8 +293,9 @@ bool AnyOfVariadicOperator(const ast_type_traits::DynTypedNode &DynNode,
|
|||
return false;
|
||||
}
|
||||
|
||||
HasNameMatcher::HasNameMatcher(StringRef NameRef)
|
||||
: UseUnqualifiedMatch(NameRef.find("::") == NameRef.npos), Name(NameRef) {
|
||||
HasNameMatcher::HasNameMatcher(std::string NameRef)
|
||||
: UseUnqualifiedMatch(NameRef.find("::") == NameRef.npos),
|
||||
Name(std::move(NameRef)) {
|
||||
assert(!Name.empty());
|
||||
}
|
||||
|
||||
|
|
|
@ -591,7 +591,7 @@ public:
|
|||
return NULLPtr;
|
||||
}
|
||||
|
||||
llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
|
||||
llvm::GlobalVariable *GetClassGlobal(StringRef Name,
|
||||
bool Weak = false) override {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -1256,7 +1256,7 @@ public:
|
|||
|
||||
/// GetClassGlobal - Return the global variable for the Objective-C
|
||||
/// class of the given name.
|
||||
llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
|
||||
llvm::GlobalVariable *GetClassGlobal(StringRef Name,
|
||||
bool Weak = false) override {
|
||||
llvm_unreachable("CGObjCMac::GetClassGlobal");
|
||||
}
|
||||
|
@ -1358,7 +1358,7 @@ private:
|
|||
|
||||
/// GetClassGlobal - Return the global variable for the Objective-C
|
||||
/// class of the given name.
|
||||
llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
|
||||
llvm::GlobalVariable *GetClassGlobal(StringRef Name,
|
||||
bool Weak = false) override;
|
||||
|
||||
/// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy,
|
||||
|
@ -6834,7 +6834,7 @@ CGObjCNonFragileABIMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF,
|
|||
}
|
||||
|
||||
llvm::GlobalVariable *
|
||||
CGObjCNonFragileABIMac::GetClassGlobal(const std::string &Name, bool Weak) {
|
||||
CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name, bool Weak) {
|
||||
llvm::GlobalValue::LinkageTypes L =
|
||||
Weak ? llvm::GlobalValue::ExternalWeakLinkage
|
||||
: llvm::GlobalValue::ExternalLinkage;
|
||||
|
|
|
@ -280,7 +280,7 @@ public:
|
|||
virtual llvm::Constant *BuildByrefLayout(CodeGen::CodeGenModule &CGM,
|
||||
QualType T) = 0;
|
||||
|
||||
virtual llvm::GlobalVariable *GetClassGlobal(const std::string &Name,
|
||||
virtual llvm::GlobalVariable *GetClassGlobal(StringRef Name,
|
||||
bool Weak = false) = 0;
|
||||
|
||||
struct MessageSendInfo {
|
||||
|
|
|
@ -241,7 +241,7 @@ public:
|
|||
: Out(out), PP(pp), idcount(0), CurStrOffset(0) {}
|
||||
|
||||
PTHMap &getPM() { return PM; }
|
||||
void GeneratePTH(const std::string &MainFile);
|
||||
void GeneratePTH(StringRef MainFile);
|
||||
};
|
||||
} // end anonymous namespace
|
||||
|
||||
|
@ -479,7 +479,7 @@ static void pwrite32le(raw_pwrite_stream &OS, uint32_t Val, uint64_t &Off) {
|
|||
Off += 4;
|
||||
}
|
||||
|
||||
void PTHWriter::GeneratePTH(const std::string &MainFile) {
|
||||
void PTHWriter::GeneratePTH(StringRef MainFile) {
|
||||
// Generate the prologue.
|
||||
Out << "cfe-pth" << '\0';
|
||||
Emit32(PTHManager::Version);
|
||||
|
|
|
@ -467,7 +467,7 @@ IntrusiveRefCntPtr<ASTReader> CompilerInstance::createPCHExternalASTSource(
|
|||
// Code Completion
|
||||
|
||||
static bool EnableCodeCompletion(Preprocessor &PP,
|
||||
const std::string &Filename,
|
||||
StringRef Filename,
|
||||
unsigned Line,
|
||||
unsigned Column) {
|
||||
// Tell the source manager to chop off the given file at a specific
|
||||
|
|
|
@ -369,18 +369,16 @@ void PrintPPOutputPPCallbacks::MacroUndefined(const Token &MacroNameTok,
|
|||
setEmittedDirectiveOnThisLine();
|
||||
}
|
||||
|
||||
static void outputPrintable(llvm::raw_ostream& OS,
|
||||
const std::string &Str) {
|
||||
for (unsigned i = 0, e = Str.size(); i != e; ++i) {
|
||||
unsigned char Char = Str[i];
|
||||
if (isPrintable(Char) && Char != '\\' && Char != '"')
|
||||
OS << (char)Char;
|
||||
else // Output anything hard as an octal escape.
|
||||
OS << '\\'
|
||||
<< (char)('0'+ ((Char >> 6) & 7))
|
||||
<< (char)('0'+ ((Char >> 3) & 7))
|
||||
<< (char)('0'+ ((Char >> 0) & 7));
|
||||
}
|
||||
static void outputPrintable(raw_ostream &OS, StringRef Str) {
|
||||
for (unsigned char Char : Str) {
|
||||
if (isPrintable(Char) && Char != '\\' && Char != '"')
|
||||
OS << (char)Char;
|
||||
else // Output anything hard as an octal escape.
|
||||
OS << '\\'
|
||||
<< (char)('0' + ((Char >> 6) & 7))
|
||||
<< (char)('0' + ((Char >> 3) & 7))
|
||||
<< (char)('0' + ((Char >> 0) & 7));
|
||||
}
|
||||
}
|
||||
|
||||
void PrintPPOutputPPCallbacks::PragmaMessage(SourceLocation Loc,
|
||||
|
|
|
@ -592,9 +592,8 @@ void getSourceTextOfDeclaration(const DeclInfo *ThisDecl,
|
|||
|
||||
void CommentASTToXMLConverter::formatTextOfDeclaration(
|
||||
const DeclInfo *DI, SmallString<128> &Declaration) {
|
||||
// FIXME. formatting API expects null terminated input string.
|
||||
// There might be more efficient way of doing this.
|
||||
std::string StringDecl = Declaration.str();
|
||||
// Formatting API expects null terminated input string.
|
||||
StringRef StringDecl(Declaration.c_str(), Declaration.size());
|
||||
|
||||
// Formatter specific code.
|
||||
// Form a unique in memory buffer name.
|
||||
|
|
|
@ -3483,7 +3483,7 @@ static bool SkipCursorToBlock(BitstreamCursor &Cursor, unsigned BlockID) {
|
|||
}
|
||||
}
|
||||
|
||||
ASTReader::ASTReadResult ASTReader::ReadAST(const std::string &FileName,
|
||||
ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
|
||||
ModuleKind Type,
|
||||
SourceLocation ImportLoc,
|
||||
unsigned ClientLoadCapabilities) {
|
||||
|
|
|
@ -412,13 +412,13 @@ void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,
|
|||
// Output a maximum size.
|
||||
if (!isa<PathDiagnosticMacroPiece>(P)) {
|
||||
// Get the string and determining its maximum substring.
|
||||
const std::string& Msg = P.getString();
|
||||
const auto &Msg = P.getString();
|
||||
unsigned max_token = 0;
|
||||
unsigned cnt = 0;
|
||||
unsigned len = Msg.size();
|
||||
|
||||
for (std::string::const_iterator I=Msg.begin(), E=Msg.end(); I!=E; ++I)
|
||||
switch (*I) {
|
||||
for (char C : Msg)
|
||||
switch (C) {
|
||||
default:
|
||||
++cnt;
|
||||
continue;
|
||||
|
|
|
@ -124,7 +124,7 @@ static void ReportControlFlow(raw_ostream &o,
|
|||
--indent;
|
||||
|
||||
// Output any helper text.
|
||||
const std::string& s = P.getString();
|
||||
const auto &s = P.getString();
|
||||
if (!s.empty()) {
|
||||
Indent(o, indent) << "<key>alternate</key>";
|
||||
EmitString(o, s) << '\n';
|
||||
|
|
|
@ -130,7 +130,7 @@ static void ApplyOneQAOverride(raw_ostream &OS,
|
|||
}
|
||||
}
|
||||
} else if (Edit[0] == 'x' || Edit[0] == 'X') {
|
||||
std::string Option = Edit.substr(1, std::string::npos);
|
||||
auto Option = Edit.substr(1);
|
||||
for (unsigned i = 1; i < Args.size();) {
|
||||
if (Option == Args[i]) {
|
||||
OS << "### Deleting argument " << Args[i] << '\n';
|
||||
|
|
Loading…
Reference in New Issue