Mercurial > hg > CbC > CbC_llvm
diff clang/lib/Lex/Preprocessor.cpp @ 207:2e18cbf3894f
LLVM12
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 08 Jun 2021 06:07:14 +0900 |
parents | 0572611fdcc8 |
children | dd44ba33042e c4bab56944e8 |
line wrap: on
line diff
--- a/clang/lib/Lex/Preprocessor.cpp Mon May 25 11:55:54 2020 +0900 +++ b/clang/lib/Lex/Preprocessor.cpp Tue Jun 08 06:07:14 2021 +0900 @@ -119,12 +119,8 @@ // 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().CPlusPlus20) { - (Ident__VA_OPT__ = getIdentifierInfo("__VA_OPT__"))->setIsPoisoned(); - SetPoisonReason(Ident__VA_OPT__,diag::ext_pp_bad_vaopt_use); - } else { - Ident__VA_OPT__ = nullptr; - } + (Ident__VA_OPT__ = getIdentifierInfo("__VA_OPT__"))->setIsPoisoned(); + SetPoisonReason(Ident__VA_OPT__,diag::ext_pp_bad_vaopt_use); // Initialize the pragma handlers. RegisterBuiltinPragmas(); @@ -278,7 +274,7 @@ llvm::errs() << " " << NumEnteredSourceFiles << " source files entered.\n"; llvm::errs() << " " << MaxIncludeStackDepth << " max include stack depth\n"; llvm::errs() << " " << NumIf << " #if/#ifndef/#ifdef.\n"; - llvm::errs() << " " << NumElse << " #else/#elif.\n"; + llvm::errs() << " " << NumElse << " #else/#elif/#elifdef/#elifndef.\n"; llvm::errs() << " " << NumEndif << " #endif.\n"; llvm::errs() << " " << NumPragma << " #pragma.\n"; llvm::errs() << NumSkipped << " #if/#ifndef#ifdef regions skipped\n"; @@ -395,12 +391,10 @@ assert(CompleteLine && CompleteColumn && "Starts from 1:1"); assert(!CodeCompletionFile && "Already set"); - using llvm::MemoryBuffer; - // Load the actual file's contents. - bool Invalid = false; - const MemoryBuffer *Buffer = SourceMgr.getMemoryBufferForFile(File, &Invalid); - if (Invalid) + Optional<llvm::MemoryBufferRef> Buffer = + SourceMgr.getMemoryBufferForFileOrNone(File); + if (!Buffer) return true; // Find the byte position of the truncation point. @@ -448,15 +442,15 @@ void Preprocessor::CodeCompleteIncludedFile(llvm::StringRef Dir, bool IsAngled) { + setCodeCompletionReached(); if (CodeComplete) CodeComplete->CodeCompleteIncludedFile(Dir, IsAngled); - setCodeCompletionReached(); } void Preprocessor::CodeCompleteNaturalLanguage() { + setCodeCompletionReached(); if (CodeComplete) CodeComplete->CodeCompleteNaturalLanguage(); - setCodeCompletionReached(); } /// getSpelling - This method is used to get the spelling of a token into a @@ -969,8 +963,10 @@ LastTokenWasAt = Result.is(tok::at); --LexLevel; - if (LexLevel == 0 && !Result.getFlag(Token::IsReinjected)) { - ++TokenCount; + if ((LexLevel == 0 || PreprocessToken) && + !Result.getFlag(Token::IsReinjected)) { + if (LexLevel == 0) + ++TokenCount; if (OnToken) OnToken(Result); } @@ -1370,7 +1366,9 @@ 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); @@ -1413,6 +1411,8 @@ CommentHandler::~CommentHandler() = default; +EmptylineHandler::~EmptylineHandler() = default; + CodeCompletionHandler::~CodeCompletionHandler() = default; void Preprocessor::createPreprocessingRecord() {