54 #include "llvm/ADT/APInt.h"
55 #include "llvm/ADT/ArrayRef.h"
56 #include "llvm/ADT/DenseMap.h"
57 #include "llvm/ADT/STLExtras.h"
58 #include "llvm/ADT/SmallString.h"
59 #include "llvm/ADT/SmallVector.h"
60 #include "llvm/ADT/StringRef.h"
61 #include "llvm/Support/Capacity.h"
62 #include "llvm/Support/ErrorHandling.h"
63 #include "llvm/Support/MemoryBuffer.h"
64 #include "llvm/Support/raw_ostream.h"
73 using namespace clang;
85 : PPOpts(
std::move(PPOpts)), Diags(&diags), LangOpts(opts),
86 FileMgr(Headers.getFileMgr()), SourceMgr(
SM),
87 ScratchBuf(new
ScratchBuffer(SourceMgr)), HeaderInfo(Headers),
88 TheModuleLoader(TheModuleLoader), ExternalSource(nullptr),
92 Identifiers(IILookup), PragmaHandlers(new
PragmaNamespace(StringRef())),
93 TUKind(TUKind), SkipMainFilePreamble(0,
true),
94 CurSubmoduleState(&NullSubmoduleState) {
95 OwnsHeaderSearch = OwnsHeaders;
99 KeepMacroComments =
false;
100 SuppressIncludeNotFoundError =
false;
103 DisableMacroExpansion =
false;
104 MacroExpansionInDirectivesOverride =
false;
107 InMacroArgPreExpansion =
false;
108 NumCachedTokenLexers = 0;
109 PragmasEnabled =
true;
110 ParsingIfOrElifDirective =
false;
111 PreprocessedOutput =
false;
114 ReadMacrosFromExternalSource =
false;
116 BuiltinInfo = std::make_unique<Builtin::Context>();
126 RegisterBuiltinPragmas();
129 RegisterBuiltinMacros();
131 if(LangOpts.Borland) {
142 Ident__exception_info = Ident__exception_code =
nullptr;
143 Ident__abnormal_termination = Ident___exception_info =
nullptr;
144 Ident___exception_code = Ident___abnormal_termination =
nullptr;
145 Ident_GetExceptionInfo = Ident_GetExceptionCode =
nullptr;
146 Ident_AbnormalTermination =
nullptr;
151 SkippingUntilPragmaHdrStop =
true;
154 if (!this->PPOpts->PCHThroughHeader.empty() &&
155 !this->PPOpts->ImplicitPCHInclude.empty())
156 SkippingUntilPCHThroughHeader =
true;
158 if (this->PPOpts->GeneratePreamble)
159 PreambleConditionalStack.startRecording();
161 MaxTokens = LangOpts.MaxTokens;
165 assert(BacktrackPositions.empty() &&
"EnableBacktrack/Backtrack imbalance!");
167 IncludeMacroStack.clear();
172 std::fill(TokenLexerCache, TokenLexerCache + NumCachedTokenLexers,
nullptr);
173 CurTokenLexer.reset();
176 for (
MacroArgs *ArgList = MacroArgCache; ArgList;)
177 ArgList = ArgList->deallocate();
180 if (OwnsHeaderSearch)
186 assert((!this->Target || this->Target == &
Target) &&
187 "Invalid override of target information");
190 assert((!this->AuxTarget || this->AuxTarget == AuxTarget) &&
191 "Invalid override of aux target information.");
192 this->AuxTarget = AuxTarget;
195 BuiltinInfo->InitializeTarget(
Target, AuxTarget);
218 NumEnteredSourceFiles = 0;
221 PragmaHandlersBackup = std::move(PragmaHandlers);
222 PragmaHandlers = std::make_unique<PragmaNamespace>(StringRef());
223 RegisterBuiltinPragmas();
226 PredefinesFileID =
FileID();
230 NumEnteredSourceFiles = 1;
232 PragmaHandlers = std::move(PragmaHandlersBackup);
241 if (!DumpFlags)
return;
243 llvm::errs() <<
"\t";
245 llvm::errs() <<
" [StartOfLine]";
247 llvm::errs() <<
" [LeadingSpace]";
249 llvm::errs() <<
" [ExpandDisabled]";
252 llvm::errs() <<
" [UnClean='" << StringRef(Start, Tok.
getLength())
256 llvm::errs() <<
"\tLoc=<";
262 Loc.
print(llvm::errs(), SourceMgr);
266 llvm::errs() <<
"MACRO: ";
267 for (
unsigned i = 0, e = MI.
getNumTokens(); i != e; ++i) {
271 llvm::errs() <<
"\n";
275 llvm::errs() <<
"\n*** Preprocessor Stats:\n";
276 llvm::errs() << NumDirectives <<
" directives found:\n";
277 llvm::errs() <<
" " << NumDefined <<
" #define.\n";
278 llvm::errs() <<
" " << NumUndefined <<
" #undef.\n";
279 llvm::errs() <<
" #include/#include_next/#import:\n";
280 llvm::errs() <<
" " << NumEnteredSourceFiles <<
" source files entered.\n";
281 llvm::errs() <<
" " << MaxIncludeStackDepth <<
" max include stack depth\n";
282 llvm::errs() <<
" " << NumIf <<
" #if/#ifndef/#ifdef.\n";
283 llvm::errs() <<
" " << NumElse <<
" #else/#elif/#elifdef/#elifndef.\n";
284 llvm::errs() <<
" " << NumEndif <<
" #endif.\n";
285 llvm::errs() <<
" " << NumPragma <<
" #pragma.\n";
286 llvm::errs() << NumSkipped <<
" #if/#ifndef#ifdef regions skipped\n";
288 llvm::errs() << NumMacroExpanded <<
"/" << NumFnMacroExpanded <<
"/"
289 << NumBuiltinMacroExpanded <<
" obj/fn/builtin macros expanded, "
290 << NumFastMacroExpanded <<
" on the fast path.\n";
291 llvm::errs() << (NumFastTokenPaste+NumTokenPaste)
292 <<
" token paste (##) operations performed, "
293 << NumFastTokenPaste <<
" on the fast path.\n";
295 llvm::errs() <<
"\nPreprocessor Memory: " <<
getTotalMemory() <<
"B total";
297 llvm::errs() <<
"\n BumpPtr: " << BP.getTotalMemory();
298 llvm::errs() <<
"\n Macro Expanded Tokens: "
299 << llvm::capacity_in_bytes(MacroExpandedTokens);
300 llvm::errs() <<
"\n Predefines Buffer: " << Predefines.capacity();
302 llvm::errs() <<
"\n Macros: "
303 << llvm::capacity_in_bytes(CurSubmoduleState->Macros);
304 llvm::errs() <<
"\n #pragma push_macro Info: "
305 << llvm::capacity_in_bytes(PragmaPushMacroInfo);
306 llvm::errs() <<
"\n Poison Reasons: "
307 << llvm::capacity_in_bytes(PoisonReasons);
308 llvm::errs() <<
"\n Comment Handlers: "
309 << llvm::capacity_in_bytes(CommentHandlers) <<
"\n";
314 if (IncludeExternalMacros && ExternalSource &&
315 !ReadMacrosFromExternalSource) {
316 ReadMacrosFromExternalSource =
true;
322 CurSubmoduleState->Macros.insert(std::make_pair(Macro.II, MacroState()));
324 return CurSubmoduleState->Macros.begin();
328 return BP.getTotalMemory()
329 + llvm::capacity_in_bytes(MacroExpandedTokens)
330 + Predefines.capacity()
333 + llvm::capacity_in_bytes(CurSubmoduleState->Macros)
334 + llvm::capacity_in_bytes(PragmaPushMacroInfo)
335 + llvm::capacity_in_bytes(PoisonReasons)
336 + llvm::capacity_in_bytes(CommentHandlers);
341 if (IncludeExternalMacros && ExternalSource &&
342 !ReadMacrosFromExternalSource) {
343 ReadMacrosFromExternalSource =
true;
347 return CurSubmoduleState->Macros.end();
354 std::equal(Tokens.begin(), Tokens.end(), MI->
tokens_begin());
361 StringRef BestSpelling;
365 Def = I->second.findDirectiveAtLoc(Loc, SourceMgr);
377 BestLocation = Location;
378 BestSpelling = I->first->getName();
386 CurLexerKind = CurLexer->isDependencyDirectivesLexer()
387 ? CLK_DependencyDirectivesLexer
389 else if (CurTokenLexer)
390 CurLexerKind = CLK_TokenLexer;
392 CurLexerKind = CLK_CachingLexer;
396 unsigned CompleteLine,
397 unsigned CompleteColumn) {
399 assert(CompleteLine && CompleteColumn &&
"Starts from 1:1");
400 assert(!CodeCompletionFile &&
"Already set");
403 std::optional<llvm::MemoryBufferRef> Buffer =
409 const char *Position = Buffer->getBufferStart();
411 for (; *Position; ++Position) {
412 if (*Position !=
'\r' && *Position !=
'\n')
416 if ((Position[1] ==
'\r' || Position[1] ==
'\n') &&
417 Position[0] != Position[1])
424 Position += CompleteColumn - 1;
428 if (SkipMainFilePreamble.first &&
430 if (Position - Buffer->getBufferStart() < SkipMainFilePreamble.first)
431 Position = Buffer->getBufferStart() + SkipMainFilePreamble.first;
434 if (Position > Buffer->getBufferEnd())
435 Position = Buffer->getBufferEnd();
437 CodeCompletionFile =
File;
438 CodeCompletionOffset = Position - Buffer->getBufferStart();
440 auto NewBuffer = llvm::WritableMemoryBuffer::getNewUninitMemBuffer(
441 Buffer->getBufferSize() + 1, Buffer->getBufferIdentifier());
442 char *NewBuf = NewBuffer->getBufferStart();
443 char *NewPos = std::copy(Buffer->getBufferStart(), Position, NewBuf);
445 std::copy(Position, Buffer->getBufferEnd(), NewPos+1);
469 bool *Invalid)
const {
471 if (Tok.
isNot(tok::raw_identifier) && !Tok.
hasUCN()) {
474 return II->getName();
481 const char *Ptr = Buffer.data();
483 return StringRef(Ptr, Len);
495 SourceLocation Loc = ScratchBuf->getToken(Str.data(), Str.size(), DestPtr);
497 if (ExpansionLocStart.
isValid())
499 ExpansionLocEnd, Str.size());
503 if (Tok.
is(tok::raw_identifier))
512 std::pair<FileID, unsigned> LocInfo =
SM.getDecomposedLoc(SpellingLoc);
513 bool Invalid =
false;
514 StringRef Buffer =
SM.getBufferData(LocInfo.first, &Invalid);
521 ScratchBuf->getToken(Buffer.data() + LocInfo.second, Length, DestPtr);
533 if (!
getLangOpts().isCompilingModuleImplementation())
549 assert(NumEnteredSourceFiles == 0 &&
"Cannot reenter the main file!");
560 if (SkipMainFilePreamble.first > 0)
561 CurLexer->SetByteOffset(SkipMainFilePreamble.first,
562 SkipMainFilePreamble.second);
571 std::unique_ptr<llvm::MemoryBuffer> SB =
572 llvm::MemoryBuffer::getMemBufferCopy(Predefines,
"<built-in>");
573 assert(SB &&
"Cannot create predefined source buffer");
575 assert(FID.
isValid() &&
"Could not create FileID for predefines?");
576 setPredefinesFileID(FID);
581 if (!PPOpts->PCHThroughHeader.empty()) {
586 false,
nullptr,
nullptr,
587 nullptr,
nullptr,
nullptr,
592 << PPOpts->PCHThroughHeader;
595 setPCHThroughHeaderFileID(
605 void Preprocessor::setPCHThroughHeaderFileID(
FileID FID) {
606 assert(PCHThroughHeaderFileID.
isInvalid() &&
607 "PCHThroughHeaderFileID already set!");
608 PCHThroughHeaderFileID = FID;
612 assert(PCHThroughHeaderFileID.
isValid() &&
613 "Invalid PCH through header FileID");
619 PCHThroughHeaderFileID.
isValid();
624 PCHThroughHeaderFileID.
isValid();
641 bool ReachedMainFileEOF =
false;
642 bool UsingPCHThroughHeader = SkippingUntilPCHThroughHeader;
643 bool UsingPragmaHdrStop = SkippingUntilPragmaHdrStop;
648 switch (CurLexerKind) {
653 CurTokenLexer->Lex(Tok);
655 case CLK_CachingLexer:
658 case CLK_DependencyDirectivesLexer:
659 CurLexer->LexDependencyDirectiveToken(Tok);
661 case CLK_LexAfterModuleImport:
666 ReachedMainFileEOF =
true;
669 if (UsingPCHThroughHeader && !SkippingUntilPCHThroughHeader)
671 if (UsingPragmaHdrStop && !SkippingUntilPragmaHdrStop)
674 if (ReachedMainFileEOF) {
675 if (UsingPCHThroughHeader)
677 << PPOpts->PCHThroughHeader << 1;
678 else if (!PPOpts->PCHWithHdrStopCreate)
683 void Preprocessor::replayPreambleConditionalStack() {
685 if (PreambleConditionalStack.isReplaying()) {
687 "CurPPLexer is null when calling replayPreambleConditionalStack.");
689 PreambleConditionalStack.doneReplaying();
690 if (PreambleConditionalStack.reachedEOFWhileSkipping())
691 SkipExcludedConditionalBlock(
692 PreambleConditionalStack.SkipInfo->HashTokenLoc,
693 PreambleConditionalStack.SkipInfo->IfTokenLoc,
694 PreambleConditionalStack.SkipInfo->FoundNonSkipPortion,
695 PreambleConditionalStack.SkipInfo->FoundElse,
696 PreambleConditionalStack.SkipInfo->ElseLoc);
703 Callbacks->EndOfMainFile();
714 assert(!
Identifier.getRawIdentifier().empty() &&
"No raw identifier data!");
749 PoisonReasons[II] = DiagID;
753 assert(Ident__exception_code && Ident__exception_info);
754 assert(Ident___exception_code && Ident___exception_info);
768 "Can't handle identifiers without identifier info!");
769 llvm::DenseMap<IdentifierInfo*,unsigned>::const_iterator it =
770 PoisonReasons.find(
Identifier.getIdentifierInfo());
771 if(it == PoisonReasons.end())
777 void Preprocessor::updateOutOfDateIdentifier(
IdentifierInfo &II)
const {
792 "Can't handle identifiers without identifier info!");
802 bool CurrentIsPoisoned =
false;
803 const bool IsSpecialVariadicMacro =
804 &II == Ident__VA_ARGS__ || &II == Ident__VA_OPT__;
805 if (IsSpecialVariadicMacro)
808 updateOutOfDateIdentifier(II);
811 if (IsSpecialVariadicMacro)
823 auto *MI = MD.getMacroInfo();
824 assert(MI &&
"macro definition with no macro info?");
825 if (!DisableMacroExpansion) {
826 if (!
Identifier.isExpandDisabled() && MI->isEnabled()) {
829 if (!MI->isFunctionLike() || isNextPPTokenLParen())
830 return HandleMacroExpandedIdentifier(
Identifier, MD);
836 if (MI->isObjectLike() || isNextPPTokenLParen())
871 !InMacroArgs && !DisableMacroExpansion &&
873 CurLexerKind != CLK_CachingLexer) {
875 NamedModuleImportPath.clear();
876 ModuleImportExpectsIdentifier =
true;
877 CurLexerKind = CLK_LexAfterModuleImport;
888 switch (CurLexerKind) {
890 ReturnedToken = CurLexer->Lex(Result);
893 ReturnedToken = CurTokenLexer->Lex(Result);
895 case CLK_CachingLexer:
897 ReturnedToken =
true;
899 case CLK_DependencyDirectivesLexer:
900 ReturnedToken = CurLexer->LexDependencyDirectiveToken(Result);
902 case CLK_LexAfterModuleImport:
906 }
while (!ReturnedToken);
911 if (Result.is(tok::code_completion) && Result.getIdentifierInfo()) {
917 Result.setIdentifierInfo(
nullptr);
925 if (
getLangOpts().CPlusPlusModules && LexLevel == 1 &&
928 case tok::l_paren:
case tok::l_square:
case tok::l_brace:
929 StdCXXImportSeqState.handleOpenBracket();
931 case tok::r_paren:
case tok::r_square:
932 StdCXXImportSeqState.handleCloseBracket();
935 StdCXXImportSeqState.handleCloseBrace();
939 case tok::annot_module_include:
941 TrackGMFState.handleSemi();
942 StdCXXImportSeqState.handleSemi();
944 case tok::header_name:
945 case tok::annot_header_unit:
946 StdCXXImportSeqState.handleHeaderName();
949 TrackGMFState.handleExport();
950 StdCXXImportSeqState.handleExport();
952 case tok::identifier:
953 if (Result.getIdentifierInfo()->isModulesImport()) {
954 TrackGMFState.handleImport(StdCXXImportSeqState.afterTopLevelSeq());
955 StdCXXImportSeqState.handleImport();
956 if (StdCXXImportSeqState.afterImportSeq()) {
958 NamedModuleImportPath.clear();
959 ModuleImportExpectsIdentifier =
true;
960 CurLexerKind = CLK_LexAfterModuleImport;
964 TrackGMFState.handleModule(StdCXXImportSeqState.afterTopLevelSeq());
969 TrackGMFState.handleMisc();
970 StdCXXImportSeqState.handleMisc();
975 LastTokenWasAt = Result.is(tok::at);
978 if ((LexLevel == 0 || PreprocessToken) &&
1009 if (FilenameTok.
is(tok::less) && AllowMacroExpansion) {
1016 FilenameBuffer.push_back(
'<');
1022 while (FilenameTok.
isNot(tok::greater)) {
1026 Diag(Start, diag::note_matching) << tok::less;
1033 if (FilenameTok.
is(tok::code_completion)) {
1042 FilenameBuffer.push_back(
' ');
1046 size_t PreAppendSize = FilenameBuffer.size();
1047 FilenameBuffer.resize(PreAppendSize + FilenameTok.
getLength());
1049 const char *BufPtr = &FilenameBuffer[PreAppendSize];
1050 unsigned ActualLen =
getSpelling(FilenameTok, BufPtr);
1053 if (BufPtr != &FilenameBuffer[PreAppendSize])
1054 memcpy(&FilenameBuffer[PreAppendSize], BufPtr, ActualLen);
1057 if (FilenameTok.
getLength() != ActualLen)
1058 FilenameBuffer.resize(PreAppendSize + ActualLen);
1062 FilenameTok.
setKind(tok::header_name);
1067 }
else if (FilenameTok.
is(tok::string_literal) && AllowMacroExpansion) {
1078 StringRef Str =
getSpelling(FilenameTok, FilenameBuffer);
1079 if (Str.size() >= 2 && Str.front() ==
'"' && Str.back() ==
'"')
1080 FilenameTok.
setKind(tok::header_name);
1091 unsigned BracketDepth = 0;
1093 Toks.emplace_back();
1096 switch (Toks.back().getKind()) {
1097 case tok::l_paren:
case tok::l_square:
case tok::l_brace:
1101 case tok::r_paren:
case tok::r_square:
case tok::r_brace:
1102 if (BracketDepth == 0)
1108 if (BracketDepth == 0)
1151 if (NamedModuleImportPath.empty() &&
getLangOpts().CPlusPlusModules) {
1161 auto ToksCopy = std::make_unique<Token[]>(Toks.size());
1162 std::copy(Toks.begin(), Toks.end(), ToksCopy.get());
1163 EnterTokenStream(std::move(ToksCopy), Toks.size(),
1169 if (Result.is(tok::header_name)) {
1173 Suffix.push_back(Result);
1178 if (Suffix.back().isNot(tok::semi)) {
1180 EnterTokens(Suffix);
1189 Diag(SemiLoc, diag::err_header_import_semi_in_macro);
1194 ImportTok.
setKind(tok::kw_import);
1199 auto Action = HandleHeaderIncludeOrImport(
1201 switch (Action.Kind) {
1205 case ImportAction::ModuleBegin:
1207 Suffix.emplace_back();
1208 Suffix.back().startToken();
1209 Suffix.back().setKind(tok::annot_module_begin);
1210 Suffix.back().setLocation(SemiLoc);
1211 Suffix.back().setAnnotationEndLoc(SemiLoc);
1212 Suffix.back().setAnnotationValue(Action.ModuleForHeader);
1215 case ImportAction::ModuleImport:
1216 case ImportAction::HeaderUnitImport:
1217 case ImportAction::SkippedModuleImport:
1220 Suffix[0].setKind(tok::annot_header_unit);
1221 Suffix[0].setAnnotationEndLoc(Suffix[0].getLocation());
1222 Suffix[0].setAnnotationValue(Action.ModuleForHeader);
1225 case ImportAction::Failure:
1227 "This should be an early exit only to a fatal error");
1229 CurLexer->cutOffLexing();
1230 EnterTokens(Suffix);
1234 EnterTokens(Suffix);
1244 if (ModuleImportExpectsIdentifier && Result.
getKind() == tok::identifier) {
1247 NamedModuleImportPath.push_back(std::make_pair(Result.getIdentifierInfo(),
1249 ModuleImportExpectsIdentifier =
false;
1250 CurLexerKind = CLK_LexAfterModuleImport;
1257 if (!ModuleImportExpectsIdentifier && Result.
getKind() == tok::period) {
1258 ModuleImportExpectsIdentifier =
true;
1259 CurLexerKind = CLK_LexAfterModuleImport;
1264 if (NamedModuleImportPath.empty() || Result.is(
tok::eof))
1270 if (Result.isNot(tok::semi)) {
1271 Suffix.push_back(Result);
1273 if (Suffix.back().isNot(tok::semi)) {
1275 EnterTokens(Suffix);
1278 SemiLoc = Suffix.back().getLocation();
1287 for (
auto &Piece : NamedModuleImportPath) {
1288 if (!FlatModuleName.empty())
1289 FlatModuleName +=
".";
1290 FlatModuleName += Piece.first->getName();
1293 NamedModuleImportPath.clear();
1294 NamedModuleImportPath.push_back(
1298 Module *Imported =
nullptr;
1300 Imported = TheModuleLoader.
loadModule(ModuleImportLoc,
1301 NamedModuleImportPath,
1308 Callbacks->moduleImport(ModuleImportLoc, NamedModuleImportPath, Imported);
1310 if (!Suffix.empty()) {
1311 EnterTokens(Suffix);
1318 CurSubmoduleState->VisibleModules.setVisible(
1323 Diag(ModuleImportLoc, diag::warn_module_conflict)
1324 << Path[0]->getFullModuleName()
1325 << Conflict->getFullModuleName()
1330 if (!BuildingSubmoduleStack.empty() && M != BuildingSubmoduleStack.back().M)
1331 BuildingSubmoduleStack.back().M->Imports.insert(M);
1335 const char *DiagnosticTag,
1336 bool AllowMacroExpansion) {
1338 if (Result.isNot(tok::string_literal)) {
1339 Diag(Result, diag::err_expected_string_literal)
1340 << 0 << DiagnosticTag;
1347 StrToks.push_back(Result);
1349 if (Result.hasUDSuffix())
1350 Diag(Result, diag::err_invalid_string_udl);
1352 if (AllowMacroExpansion)
1356 }
while (Result.is(tok::string_literal));
1360 assert(
Literal.isOrdinary() &&
"Didn't allow wide strings in");
1366 Diag(StrToks[0].getLocation(), diag::err_expected_string_literal)
1367 << 0 << DiagnosticTag;
1376 assert(Tok.
is(tok::numeric_constant));
1378 bool NumberInvalid =
false;
1379 StringRef Spelling =
getSpelling(Tok, IntegerBuffer, &NumberInvalid);
1388 if (
Literal.GetIntegerValue(APVal))
1391 Value = APVal.getLimitedValue();
1396 assert(Handler &&
"NULL comment handler");
1397 assert(!llvm::is_contained(CommentHandlers, Handler) &&
1398 "Comment handler already registered");
1399 CommentHandlers.push_back(Handler);
1403 std::vector<CommentHandler *>::iterator Pos =
1404 llvm::find(CommentHandlers, Handler);
1405 assert(Pos != CommentHandlers.end() &&
"Comment handler not registered");
1406 CommentHandlers.erase(Pos);
1410 bool AnyPendingTokens =
false;
1411 for (std::vector<CommentHandler *>::iterator H = CommentHandlers.begin(),
1412 HEnd = CommentHandlers.end();
1414 if ((*H)->HandleComment(*
this, Comment))
1415 AnyPendingTokens =
true;
1423 void Preprocessor::emitMacroDeprecationWarning(
const Token &
Identifier)
const {
1424 const MacroAnnotations &A =
1426 assert(A.DeprecationInfo &&
1427 "Macro deprecation warning without recorded annotation!");
1428 const MacroAnnotationInfo &Info = *A.DeprecationInfo;
1429 if (Info.Message.empty())
1434 <<
Identifier.getIdentifierInfo() << 1 << Info.Message;
1435 Diag(Info.Location, diag::note_pp_macro_annotation) << 0;
1438 void Preprocessor::emitRestrictExpansionWarning(
const Token &
Identifier)
const {
1439 const MacroAnnotations &A =
1441 assert(A.RestrictExpansionInfo &&
1442 "Macro restricted expansion warning without recorded annotation!");
1443 const MacroAnnotationInfo &Info = *A.RestrictExpansionInfo;
1444 if (Info.Message.empty())
1449 <<
Identifier.getIdentifierInfo() << 1 << Info.Message;
1450 Diag(Info.Location, diag::note_pp_macro_annotation) << 1;
1454 bool IsUndef)
const {
1455 const MacroAnnotations &A =
1457 assert(A.FinalAnnotationLoc &&
1458 "Final macro warning without recorded annotation!");
1461 <<
Identifier.getIdentifierInfo() << (IsUndef ? 0 : 1);
1462 Diag(*A.FinalAnnotationLoc, diag::note_pp_macro_annotation) << 2;