[clang-tidy] Fix a use-after-free bug found by asan

llvm-svn: 256562
This commit is contained in:
Alexander Kornienko 2015-12-29 16:14:38 +00:00
parent c2e4bb421a
commit 254825a356
1 changed files with 3 additions and 2 deletions

View File

@ -491,9 +491,10 @@ void SimplifyBooleanExprCheck::check(const MatchFinder::MatchResult &Result) {
bool containsDiscardedTokens(
const ast_matchers::MatchFinder::MatchResult &Result,
CharSourceRange CharRange) {
StringRef ReplacementText =
std::string ReplacementText =
Lexer::getSourceText(CharRange, *Result.SourceManager,
Result.Context->getLangOpts()).str();
Result.Context->getLangOpts())
.str();
Lexer Lex(CharRange.getBegin(), Result.Context->getLangOpts(),
ReplacementText.data(), ReplacementText.data(),
ReplacementText.data() + ReplacementText.size());