Skip to content

Commit 3ef8a8d

Browse files
committed
Fix assert failure
1 parent 43de457 commit 3ef8a8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

clang-tools-extra/clang-tidy/modernize/UseConcisePreprocessorDirectivesCheck.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,13 @@ class IfPreprocessorCallbacks final : public PPCallbacks {
3636
private:
3737
void impl(SourceLocation DirectiveLoc, SourceRange ConditionRange,
3838
const llvm::StringLiteral (&Replacements)[2]) {
39-
const StringRef Condition =
39+
// Lexer requires its input range to be null-terminated.
40+
SmallString<128> Condition =
4041
Lexer::getSourceText(CharSourceRange::getTokenRange(ConditionRange),
4142
PP.getSourceManager(), PP.getLangOpts());
43+
Condition.push_back('\0');
4244
Lexer Lex(DirectiveLoc, PP.getLangOpts(), Condition.data(),
43-
Condition.data(), Condition.data() + Condition.size());
45+
Condition.data(), Condition.data() + Condition.size() - 1);
4446
Token Tok;
4547
bool Inverted = false; // The inverted form of #*def is #*ndef.
4648
std::size_t ParensNestingDepth = 0;

0 commit comments

Comments
 (0)