Add an overload of Preprocessor::getSpelling which takes a SmallVector and

returns a StringRef. Use it to simplify some repetitive code.

llvm-svn: 97322
This commit is contained in:
Benjamin Kramer
2010-02-27 13:44:12 +00:00
parent 09597b461d
commit 0a1abd4088
9 changed files with 34 additions and 39 deletions

View File

@@ -67,12 +67,7 @@ static void PrintMacroDefinition(const IdentifierInfo &II, const MacroInfo &MI,
if (I->hasLeadingSpace())
OS << ' ';
// Make sure we have enough space in the spelling buffer.
if (I->getLength() > SpellingBuffer.size())
SpellingBuffer.resize(I->getLength());
const char *Buffer = SpellingBuffer.data();
unsigned SpellingLen = PP.getSpelling(*I, Buffer);
OS.write(Buffer, SpellingLen);
OS << PP.getSpelling(*I, SpellingBuffer);
}
}