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/PrintPreprocessedOutput.cpp | |
parent | 2193e23cd72731c0d46a4ca8f09efe88b1c5f7b2 (diff) | |
download | llvm-0772c42385c0d005db0ba75ecbcc54d353763282.zip llvm-0772c42385c0d005db0ba75ecbcc54d353763282.tar.gz llvm-0772c42385c0d005db0ba75ecbcc54d353763282.tar.bz2 |
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/PrintPreprocessedOutput.cpp')
-rw-r--r-- | clang/lib/Frontend/PrintPreprocessedOutput.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/clang/lib/Frontend/PrintPreprocessedOutput.cpp b/clang/lib/Frontend/PrintPreprocessedOutput.cpp index 8a90b56..88262eb 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, |