diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2020-07-31 21:22:58 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2020-07-31 21:22:58 +0000 |
commit | 5ffd83dbcc34f10e07f6d3e968ae6365869615f4 (patch) | |
tree | 0e9f5cf729dde39f949698fddef45a34e2bc7f44 /contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp | |
parent | 1799696096df87b52968b8996d00c91e0a5de8d9 (diff) | |
parent | cfca06d7963fa0909f90483b42a6d7d194d01e08 (diff) |
Notes
Diffstat (limited to 'contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp b/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp index 0e9be3923630..160e2b6ed884 100644 --- a/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp +++ b/contrib/llvm-project/clang/lib/Lex/Preprocessor.cpp @@ -119,7 +119,7 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, // a macro. They get unpoisoned where it is allowed. (Ident__VA_ARGS__ = getIdentifierInfo("__VA_ARGS__"))->setIsPoisoned(); SetPoisonReason(Ident__VA_ARGS__,diag::ext_pp_bad_vaargs_use); - if (getLangOpts().CPlusPlus2a) { + if (getLangOpts().CPlusPlus20) { (Ident__VA_OPT__ = getIdentifierInfo("__VA_OPT__"))->setIsPoisoned(); SetPoisonReason(Ident__VA_OPT__,diag::ext_pp_bad_vaopt_use); } else { @@ -166,6 +166,8 @@ Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts, this->PPOpts->ExcludedConditionalDirectiveSkipMappings; if (ExcludedConditionalDirectiveSkipMappings) ExcludedConditionalDirectiveSkipMappings->clear(); + + MaxTokens = LangOpts.MaxTokens; } Preprocessor::~Preprocessor() { @@ -769,9 +771,13 @@ static diag::kind getFutureCompatDiagKind(const IdentifierInfo &II, return llvm::StringSwitch<diag::kind>(II.getName()) #define CXX11_KEYWORD(NAME, FLAGS) \ .Case(#NAME, diag::warn_cxx11_keyword) -#define CXX2A_KEYWORD(NAME, FLAGS) \ - .Case(#NAME, diag::warn_cxx2a_keyword) +#define CXX20_KEYWORD(NAME, FLAGS) \ + .Case(#NAME, diag::warn_cxx20_keyword) #include "clang/Basic/TokenKinds.def" + // char8_t is not modeled as a CXX20_KEYWORD because it's not + // unconditionally enabled in C++20 mode. (It can be disabled + // by -fno-char8_t.) + .Case("char8_t", diag::warn_cxx20_keyword) ; llvm_unreachable( @@ -906,6 +912,9 @@ void Preprocessor::Lex(Token &Result) { } } while (!ReturnedToken); + if (Result.is(tok::unknown) && TheModuleLoader.HadFatalFailure) + return; + if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) { // Remember the identifier before code completion token. setCodeCompletionIdentifierInfo(Result.getIdentifierInfo()); @@ -959,8 +968,12 @@ void Preprocessor::Lex(Token &Result) { LastTokenWasAt = Result.is(tok::at); --LexLevel; - if (OnToken && LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) - OnToken(Result); + + if (LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) { + ++TokenCount; + if (OnToken) + OnToken(Result); + } } /// Lex a header-name token (including one formed from header-name-tokens if @@ -1200,6 +1213,13 @@ bool Preprocessor::LexAfterModuleImport(Token &Result) { Suffix[0].setAnnotationValue(Action.ModuleForHeader); // FIXME: Call the moduleImport callback? break; + case ImportAction::Failure: + assert(TheModuleLoader.HadFatalFailure && + "This should be an early exit only to a fatal error"); + Result.setKind(tok::eof); + CurLexer->cutOffLexing(); + EnterTokens(Suffix); + return true; } EnterTokens(Suffix); @@ -1339,7 +1359,7 @@ bool Preprocessor::FinishLexStringLiteral(Token &Result, std::string &String, return false; } - String = Literal.GetString(); + String = std::string(Literal.GetString()); return true; } @@ -1350,7 +1370,9 @@ bool Preprocessor::parseSimpleIntegerLiteral(Token &Tok, uint64_t &Value) { StringRef Spelling = getSpelling(Tok, IntegerBuffer, &NumberInvalid); if (NumberInvalid) return false; - NumericLiteralParser Literal(Spelling, Tok.getLocation(), *this); + NumericLiteralParser Literal(Spelling, Tok.getLocation(), getSourceManager(), + getLangOpts(), getTargetInfo(), + getDiagnostics()); if (Literal.hadError || !Literal.isIntegerLiteral() || Literal.hasUDSuffix()) return false; llvm::APInt APVal(64, 0); |