diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2015-03-29 19:05:27 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2015-03-29 19:05:27 +0000 |
commit | 0a126adc68541f8f3db60fa1ede1df200486b66a (patch) | |
tree | 6130771a6583533b76f25d1accf6139fe386f2c2 /clang/lib/Lex/PPMacroExpansion.cpp | |
parent | 851f310cec3376982097f2ff69b6d8d5d00af785 (diff) | |
download | bcm5719-llvm-0a126adc68541f8f3db60fa1ede1df200486b66a.tar.gz bcm5719-llvm-0a126adc68541f8f3db60fa1ede1df200486b66a.zip |
[lex] Provide a valid token when __has_include is found outside of a pp directive
ExpandBuiltinMacro would strip the identifier and downstream users crash
when they encounter an identifier token with nullptr identifier info.
Found by afl-fuzz.
llvm-svn: 233497
Diffstat (limited to 'clang/lib/Lex/PPMacroExpansion.cpp')
-rw-r--r-- | clang/lib/Lex/PPMacroExpansion.cpp | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp index f2baddd0b83..3ceba05401a 100644 --- a/clang/lib/Lex/PPMacroExpansion.cpp +++ b/clang/lib/Lex/PPMacroExpansion.cpp @@ -1073,6 +1073,9 @@ static bool EvaluateHasIncludeCommon(Token &Tok, // These expressions are only allowed within a preprocessor directive. if (!PP.isParsingIfOrElifDirective()) { PP.Diag(LParenLoc, diag::err_pp_directive_required) << II->getName(); + // Return a valid identifier token. + assert(Tok.is(tok::identifier)); + Tok.setIdentifierInfo(II); return false; } |