diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2016-02-13 13:42:54 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2016-02-13 13:42:54 +0000 |
commit | 0772c42385c0d005db0ba75ecbcc54d353763282 (patch) | |
tree | d1dc6509a577aee07be533cbae15939b0aa32f2c /clang/lib/Frontend | |
parent | 2193e23cd72731c0d46a4ca8f09efe88b1c5f7b2 (diff) | |
download | bcm5719-llvm-0772c42385c0d005db0ba75ecbcc54d353763282.tar.gz bcm5719-llvm-0772c42385c0d005db0ba75ecbcc54d353763282.zip |
Reduce the number of implicit StringRef->std::string conversions by threading StringRef through more APIs.
No functionality change intended.
llvm-svn: 260815
Diffstat (limited to 'clang/lib/Frontend')
-rw-r--r-- | clang/lib/Frontend/CacheTokens.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Frontend/CompilerInstance.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 22 |
3 files changed, 13 insertions, 15 deletions
diff --git a/clang/lib/Frontend/CacheTokens.cpp b/clang/lib/Frontend/CacheTokens.cpp index 87f3d172581..15b0adab7c5 100644 --- a/clang/lib/Frontend/CacheTokens.cpp +++ b/clang/lib/Frontend/CacheTokens.cpp @@ -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); diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp index 3edcf5d654b..2b940ce360c 100644 --- a/clang/lib/Frontend/CompilerInstance.cpp +++ b/clang/lib/Frontend/CompilerInstance.cpp @@ -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 diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 8a90b56ff36..88262ebef3e 100644 --- a/clang/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/clang/lib/Frontend/PrintPreprocessedOutput.cpp @@ -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, |