Calculate size of buffer instead of using a magic value.

Patch by Matthew Davis!

Differential Revision: https://reviews.llvm.org/D41421

llvm-svn: 321757
This commit is contained in:
Paul Robinson 2018-01-03 20:29:49 +00:00
parent f344987cad
commit 4bb85ac544

View File

@ -752,7 +752,7 @@ static void PrintPreprocessedTokens(Preprocessor &PP, Token &Tok,
} else if (Tok.isLiteral() && !Tok.needsCleaning() &&
Tok.getLiteralData()) {
OS.write(Tok.getLiteralData(), Tok.getLength());
} else if (Tok.getLength() < 256) {
} else if (Tok.getLength() < llvm::array_lengthof(Buffer)) {
const char *TokPtr = Buffer;
unsigned Len = PP.getSpelling(Tok, TokPtr);
OS.write(TokPtr, Len);