25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/SmallString.h"
27 #include "llvm/ADT/StringSwitch.h"
28 #include "llvm/Config/llvm-config.h"
29 #include "llvm/Support/ErrorHandling.h"
30 #include "llvm/Support/Format.h"
31 #include "llvm/Support/raw_ostream.h"
34 using namespace clang;
40 auto Pos = CurSubmoduleState->Macros.find(II);
41 return Pos == CurSubmoduleState->Macros.end() ?
nullptr
42 : Pos->second.getLatest();
46 assert(MD &&
"MacroDirective should be non-zero!");
47 assert(!MD->
getPrevious() &&
"Already attached to a MacroDirective history.");
49 MacroState &StoredMD = CurSubmoduleState->Macros[II];
50 auto *OldMD = StoredMD.getLatest();
52 StoredMD.setLatest(MD);
53 StoredMD.overrideActiveModuleMacros(*
this, II);
55 if (needModuleMacros()) {
59 PendingModuleMacroNames.push_back(II);
64 if (!MD->
isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
73 MacroState &StoredMD = CurSubmoduleState->Macros[II];
74 assert(!StoredMD.getLatest() &&
75 "the macro history was modified before initializing it from a pch");
79 if (!MD->
isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
87 llvm::FoldingSetNodeID
ID;
91 if (
auto *MM = ModuleMacros.FindNodeOrInsertPos(ID, InsertPos)) {
97 ModuleMacros.InsertNode(MM, InsertPos);
101 for (
auto *O : Overrides) {
102 HidAny |= (O->NumOverriddenBy == 0);
103 ++O->NumOverriddenBy;
107 auto &LeafMacros = LeafModuleMacros[II];
109 LeafMacros.erase(std::remove_if(LeafMacros.begin(), LeafMacros.end(),
111 return MM->NumOverriddenBy != 0;
117 LeafMacros.push_back(MM);
126 llvm::FoldingSetNodeID
ID;
130 return ModuleMacros.FindNodeOrInsertPos(ID, InsertPos);
133 void Preprocessor::updateModuleMacroInfo(
const IdentifierInfo *II,
134 ModuleMacroInfo &Info) {
135 assert(Info.ActiveModuleMacrosGeneration !=
136 CurSubmoduleState->VisibleModules.getGeneration() &&
137 "don't need to update this macro name info");
138 Info.ActiveModuleMacrosGeneration =
139 CurSubmoduleState->VisibleModules.getGeneration();
141 auto Leaf = LeafModuleMacros.find(II);
142 if (Leaf == LeafModuleMacros.end()) {
147 Info.ActiveModuleMacros.clear();
150 llvm::DenseMap<ModuleMacro *, int> NumHiddenOverrides;
151 for (
auto *O : Info.OverriddenMacros)
152 NumHiddenOverrides[O] = -1;
156 for (
auto *LeafMM : Leaf->second) {
157 assert(LeafMM->getNumOverridingMacros() == 0 &&
"leaf macro overridden");
158 if (NumHiddenOverrides.lookup(LeafMM) == 0)
159 Worklist.push_back(LeafMM);
161 while (!Worklist.empty()) {
162 auto *MM = Worklist.pop_back_val();
163 if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
166 if (MM->getMacroInfo())
167 Info.ActiveModuleMacros.push_back(MM);
169 for (
auto *O : MM->overrides())
170 if ((
unsigned)++NumHiddenOverrides[O] == O->getNumOverridingMacros())
171 Worklist.push_back(O);
175 std::reverse(Info.ActiveModuleMacros.begin(), Info.ActiveModuleMacros.end());
179 bool IsSystemMacro =
true;
180 bool IsAmbiguous =
false;
181 if (
auto *MD = Info.MD) {
182 while (MD && isa<VisibilityMacroDirective>(MD))
183 MD = MD->getPrevious();
184 if (
auto *DMD = dyn_cast_or_null<DefMacroDirective>(MD)) {
189 for (
auto *Active : Info.ActiveModuleMacros) {
190 auto *NewMI = Active->getMacroInfo();
201 if (MI && NewMI != MI &&
202 !MI->isIdenticalTo(*NewMI, *
this,
true))
204 IsSystemMacro &= Active->getOwningModule()->IsSystem ||
208 Info.IsAmbiguous = IsAmbiguous && !IsSystemMacro;
213 auto LeafIt = LeafModuleMacros.find(II);
214 if (LeafIt != LeafModuleMacros.end())
215 Leaf = LeafIt->second;
216 const MacroState *
State =
nullptr;
217 auto Pos = CurSubmoduleState->Macros.find(II);
218 if (Pos != CurSubmoduleState->Macros.end())
219 State = &Pos->second;
223 llvm::errs() <<
" ambiguous";
224 if (
State && !
State->getOverriddenMacros().empty()) {
225 llvm::errs() <<
" overrides";
226 for (
auto *O :
State->getOverriddenMacros())
227 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
229 llvm::errs() <<
"\n";
232 for (
auto *MD =
State ?
State->getLatest() :
nullptr; MD;
233 MD = MD->getPrevious()) {
240 for (
auto *MM :
State ?
State->getActiveModuleMacros(*
this, II) :
None)
244 while (!Worklist.empty()) {
245 auto *MM = Worklist.pop_back_val();
246 llvm::errs() <<
" ModuleMacro " << MM <<
" "
247 << MM->getOwningModule()->getFullModuleName();
248 if (!MM->getMacroInfo())
249 llvm::errs() <<
" undef";
251 if (Active.count(MM))
252 llvm::errs() <<
" active";
253 else if (!CurSubmoduleState->VisibleModules.isVisible(
254 MM->getOwningModule()))
255 llvm::errs() <<
" hidden";
256 else if (MM->getMacroInfo())
257 llvm::errs() <<
" overridden";
259 if (!MM->overrides().empty()) {
260 llvm::errs() <<
" overrides";
261 for (
auto *O : MM->overrides()) {
262 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
263 if (Visited.insert(O).second)
264 Worklist.push_back(O);
267 llvm::errs() <<
"\n";
268 if (
auto *MI = MM->getMacroInfo()) {
271 llvm::errs() <<
"\n";
292 void Preprocessor::RegisterBuiltinMacros() {
301 if (LangOpts.CPlusPlus)
302 Ident__has_cpp_attribute =
305 Ident__has_cpp_attribute =
nullptr;
313 if (LangOpts.MicrosoftExt) {
317 Ident__identifier =
nullptr;
318 Ident__pragma =
nullptr;
337 Ident__MODULE__ =
nullptr;
348 if (!II)
return true;
358 if (ExpansionMI->isEnabled() &&
377 bool Preprocessor::isNextPPTokenLParen() {
381 Val = CurLexer->isNextPPTokenLParen();
382 else if (CurPTHLexer)
383 Val = CurPTHLexer->isNextPPTokenLParen();
385 Val = CurTokenLexer->isNextTokenLParen();
393 for (
unsigned i = IncludeMacroStack.size(); i != 0; --i) {
394 IncludeStackInfo &Entry = IncludeMacroStack[i-1];
396 Val = Entry.TheLexer->isNextPPTokenLParen();
397 else if (Entry.ThePTHLexer)
398 Val = Entry.ThePTHLexer->isNextPPTokenLParen();
400 Val = Entry.TheTokenLexer->isNextTokenLParen();
406 if (Entry.ThePPLexer)
419 bool Preprocessor::HandleMacroExpandedIdentifier(
Token &Identifier,
431 Callbacks->MacroExpands(Identifier, M, Identifier.
getLocation(),
433 ExpandBuiltinMacro(Identifier);
452 Args = ReadFunctionLikeMacroArgs(Identifier, MI, ExpansionEnd);
458 if (!Args)
return true;
460 ++NumFnMacroExpanded;
470 SourceRange ExpansionRange(ExpandLoc, ExpansionEnd);
478 DelayedMacroExpandsCallbacks.push_back(
479 MacroExpandsInfo(Identifier, M, ExpansionRange));
481 Callbacks->MacroExpands(Identifier, M, ExpansionRange, Args);
482 if (!DelayedMacroExpandsCallbacks.empty()) {
483 for (
unsigned i=0, e = DelayedMacroExpandsCallbacks.size(); i!=e; ++i) {
484 MacroExpandsInfo &Info = DelayedMacroExpandsCallbacks[i];
486 Callbacks->MacroExpands(Info.Tok, Info.MD, Info.Range,
489 DelayedMacroExpandsCallbacks.clear();
496 Diag(Identifier, diag::warn_pp_ambiguous_macro)
513 if (Args) Args->
destroy(*
this);
518 PropagateLineStartLeadingSpaceInfo(Identifier);
519 ++NumFastMacroExpanded;
529 if (Args) Args->
destroy(*
this);
554 if (!NewMI->isEnabled() || NewMI == MI) {
559 Diag(Identifier, diag::pp_disabled_macro_expansion);
565 ++NumFastMacroExpanded;
570 EnterMacro(Identifier, ExpansionEnd, MI, Args);
586 if (
I->is(tok::l_paren)) {
587 Brackets.push_back(
Paren);
588 }
else if (
I->is(tok::r_paren)) {
589 if (Brackets.empty() || Brackets.back() ==
Brace)
592 }
else if (
I->is(tok::l_brace)) {
593 Brackets.push_back(
Brace);
594 }
else if (
I->is(tok::r_brace)) {
595 if (Brackets.empty() || Brackets.back() ==
Paren)
600 return Brackets.empty();
634 bool FoundSeparatorToken =
false;
638 if (
I->is(tok::l_brace)) {
640 }
else if (
I->is(tok::r_brace)) {
642 if (Braces == 0 && ClosingBrace ==
E && FoundSeparatorToken)
649 FoundSeparatorToken =
true;
650 I->setKind(tok::comma);
658 if (FoundSeparatorToken && ArgStartIterator->is(tok::l_brace)) {
666 if (FoundSeparatorToken) {
668 TempToken.
setKind(tok::l_paren);
669 TempToken.
setLocation(ArgStartIterator->getLocation());
671 NewTokens.push_back(TempToken);
675 NewTokens.insert(NewTokens.end(), ArgStartIterator,
I);
678 if (FoundSeparatorToken) {
681 TempToken.
setKind(tok::r_paren);
684 NewTokens.push_back(TempToken);
685 ParenHints.push_back(
SourceRange(ArgStartIterator->getLocation(),
690 NewTokens.push_back(*
I);
693 ArgStartIterator =
I + 1;
694 FoundSeparatorToken =
false;
699 return !ParenHints.empty() && InitLists.empty();
706 MacroArgs *Preprocessor::ReadFunctionLikeMacroArgs(
Token &MacroName,
719 assert(Tok.
is(tok::l_paren) &&
"Error computing l-paren-ness?");
725 bool ContainsCodeCompletionTok =
false;
726 bool FoundElidedComma =
false;
730 unsigned NumActuals = 0;
731 while (Tok.
isNot(tok::r_paren)) {
735 assert(Tok.
isOneOf(tok::l_paren, tok::comma) &&
736 "only expect argument separators here");
738 unsigned ArgTokenStart = ArgTokens.size();
743 unsigned NumParens = 0;
751 if (!ContainsCodeCompletionTok) {
752 Diag(MacroName, diag::err_unterm_macro_invoc);
760 auto Toks = llvm::make_unique<Token[]>(1);
762 EnterTokenStream(std::move(Toks), 1,
true);
764 }
else if (Tok.
is(tok::r_paren)) {
766 if (NumParens-- == 0) {
768 if (!ArgTokens.empty() &&
769 ArgTokens.back().commaAfterElided()) {
770 FoundElidedComma =
true;
774 }
else if (Tok.
is(tok::l_paren)) {
776 }
else if (Tok.
is(tok::comma) && NumParens == 0 &&
785 if (!isVariadic)
break;
786 if (NumFixedArgsLeft > 1)
788 }
else if (Tok.
is(tok::comment) && !KeepMacroComments) {
802 }
else if (Tok.
is(tok::code_completion)) {
803 ContainsCodeCompletionTok =
true;
812 ArgTokens.push_back(Tok);
817 if (ArgTokens.empty() && Tok.
getKind() == tok::r_paren)
822 if (!isVariadic && NumFixedArgsLeft == 0 && TooManyArgsLoc.
isInvalid()) {
823 if (ArgTokens.size() != ArgTokenStart)
824 TooManyArgsLoc = ArgTokens[ArgTokenStart].getLocation();
826 TooManyArgsLoc = ArgStartLoc;
831 if (ArgTokens.size() == ArgTokenStart && !LangOpts.C99)
832 Diag(Tok, LangOpts.CPlusPlus11 ?
833 diag::warn_cxx98_compat_empty_fnmacro_arg :
834 diag::ext_empty_fnmacro_arg);
842 ArgTokens.push_back(EOFTok);
844 if (!ContainsCodeCompletionTok && NumFixedArgsLeft != 0)
854 if (!isVariadic && NumActuals > MinArgsExpected &&
855 !ContainsCodeCompletionTok) {
858 Diag(TooManyArgsLoc, diag::err_too_many_args_in_macro_invoc);
868 unsigned FixedNumArgs = 0;
871 ParenHints, InitLists)) {
872 if (!InitLists.empty()) {
875 diag::note_init_list_at_beginning_of_macro_argument);
881 if (FixedNumArgs != MinArgsExpected)
889 ArgTokens.swap(FixedArgTokens);
890 NumActuals = FixedNumArgs;
894 bool isVarargsElided =
false;
896 if (ContainsCodeCompletionTok) {
903 for (; NumActuals < MinArgsExpected; ++NumActuals)
904 ArgTokens.push_back(EOFTok);
907 if (NumActuals < MinArgsExpected) {
909 if (NumActuals == 0 && MinArgsExpected == 1) {
916 }
else if ((FoundElidedComma || MI->
isVariadic()) &&
917 (NumActuals+1 == MinArgsExpected ||
918 (NumActuals == 0 && MinArgsExpected == 2))) {
926 Diag(Tok, diag::ext_missing_varargs_arg);
937 isVarargsElided =
true;
938 }
else if (!ContainsCodeCompletionTok) {
940 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
952 ArgTokens.push_back(Tok);
955 if (NumActuals == 0 && MinArgsExpected == 2)
956 ArgTokens.push_back(Tok);
958 }
else if (NumActuals > MinArgsExpected && !MI->
isVariadic() &&
959 !ContainsCodeCompletionTok) {
962 Diag(MacroName, diag::err_too_many_args_in_macro_invoc);
982 size_t newIndex = MacroExpandedTokens.size();
983 bool cacheNeedsToGrow = tokens.size() >
984 MacroExpandedTokens.capacity()-MacroExpandedTokens.size();
985 MacroExpandedTokens.append(tokens.begin(), tokens.end());
987 if (cacheNeedsToGrow) {
990 for (
unsigned i = 0, e = MacroExpandingLexersStack.size(); i != e; ++i) {
993 std::tie(prevLexer, tokIndex) = MacroExpandingLexersStack[i];
994 prevLexer->Tokens = MacroExpandedTokens.data() + tokIndex;
998 MacroExpandingLexersStack.push_back(std::make_pair(tokLexer, newIndex));
999 return MacroExpandedTokens.data() + newIndex;
1002 void Preprocessor::removeCachedMacroExpandedTokensOfLastLexer() {
1003 assert(!MacroExpandingLexersStack.empty());
1004 size_t tokIndex = MacroExpandingLexersStack.back().second;
1005 assert(tokIndex < MacroExpandedTokens.size());
1007 MacroExpandedTokens.resize(tokIndex);
1008 MacroExpandingLexersStack.pop_back();
1016 time_t TT = time(
nullptr);
1017 struct tm *TM = localtime(&TT);
1019 static const char *
const Months[] = {
1020 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
1025 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1026 TmpStream << llvm::format(
"\"%s %2d %4d\"", Months[TM->tm_mon],
1027 TM->tm_mday, TM->tm_year + 1900);
1036 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1037 TmpStream << llvm::format(
"\"%02d:%02d:%02d\"",
1038 TM->tm_hour, TM->tm_min, TM->tm_sec);
1053 if (Feature.startswith(
"__") && Feature.endswith(
"__") && Feature.size() >= 4)
1054 Feature = Feature.substr(2, Feature.size() - 4);
1056 return llvm::StringSwitch<bool>(Feature)
1057 .Case(
"address_sanitizer",
1059 SanitizerKind::KernelAddress))
1060 .Case(
"assume_nonnull",
true)
1061 .Case(
"attribute_analyzer_noreturn",
true)
1062 .Case(
"attribute_availability",
true)
1063 .Case(
"attribute_availability_with_message",
true)
1064 .Case(
"attribute_availability_app_extension",
true)
1065 .Case(
"attribute_availability_with_version_underscores",
true)
1066 .Case(
"attribute_availability_tvos",
true)
1067 .Case(
"attribute_availability_watchos",
true)
1068 .Case(
"attribute_availability_with_strict",
true)
1069 .Case(
"attribute_availability_with_replacement",
true)
1070 .Case(
"attribute_availability_in_templates",
true)
1071 .Case(
"attribute_cf_returns_not_retained",
true)
1072 .Case(
"attribute_cf_returns_retained",
true)
1073 .Case(
"attribute_cf_returns_on_parameters",
true)
1074 .Case(
"attribute_deprecated_with_message",
true)
1075 .Case(
"attribute_deprecated_with_replacement",
true)
1076 .Case(
"attribute_ext_vector_type",
true)
1077 .Case(
"attribute_ns_returns_not_retained",
true)
1078 .Case(
"attribute_ns_returns_retained",
true)
1079 .Case(
"attribute_ns_consumes_self",
true)
1080 .Case(
"attribute_ns_consumed",
true)
1081 .Case(
"attribute_cf_consumed",
true)
1082 .Case(
"attribute_objc_ivar_unused",
true)
1083 .Case(
"attribute_objc_method_family",
true)
1084 .Case(
"attribute_overloadable",
true)
1085 .Case(
"attribute_unavailable_with_message",
true)
1086 .Case(
"attribute_unused_on_fields",
true)
1087 .Case(
"blocks", LangOpts.Blocks)
1088 .Case(
"c_thread_safety_attributes",
true)
1089 .Case(
"cxx_exceptions", LangOpts.CXXExceptions)
1090 .Case(
"cxx_rtti", LangOpts.RTTI && LangOpts.RTTIData)
1091 .Case(
"enumerator_attributes",
true)
1092 .Case(
"nullability",
true)
1093 .Case(
"memory_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::Memory))
1094 .Case(
"thread_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::Thread))
1095 .Case(
"dataflow_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::DataFlow))
1096 .Case(
"efficiency_sanitizer",
1099 .Case(
"objc_arr", LangOpts.ObjCAutoRefCount)
1100 .Case(
"objc_arc", LangOpts.ObjCAutoRefCount)
1101 .Case(
"objc_arc_weak", LangOpts.ObjCWeak)
1102 .Case(
"objc_default_synthesize_properties", LangOpts.ObjC2)
1103 .Case(
"objc_fixed_enum", LangOpts.ObjC2)
1104 .Case(
"objc_instancetype", LangOpts.ObjC2)
1105 .Case(
"objc_kindof", LangOpts.ObjC2)
1106 .Case(
"objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
1108 .Case(
"objc_property_explicit_atomic",
1110 .Case(
"objc_protocol_qualifier_mangling",
true)
1112 .Case(
"ownership_holds",
true)
1113 .Case(
"ownership_returns",
true)
1114 .Case(
"ownership_takes",
true)
1115 .Case(
"objc_bool",
true)
1117 .Case(
"objc_array_literals", LangOpts.ObjC2)
1118 .Case(
"objc_dictionary_literals", LangOpts.ObjC2)
1119 .Case(
"objc_boxed_expressions", LangOpts.ObjC2)
1120 .Case(
"objc_boxed_nsvalue_expressions", LangOpts.ObjC2)
1121 .Case(
"arc_cf_code_audited",
true)
1122 .Case(
"objc_bridge_id",
true)
1123 .Case(
"objc_bridge_id_on_typedefs",
true)
1124 .Case(
"objc_generics", LangOpts.ObjC2)
1125 .Case(
"objc_generics_variance", LangOpts.ObjC2)
1126 .Case(
"objc_class_property", LangOpts.ObjC2)
1128 .Case(
"c_alignas", LangOpts.C11)
1129 .Case(
"c_alignof", LangOpts.C11)
1130 .Case(
"c_atomic", LangOpts.C11)
1131 .Case(
"c_generic_selections", LangOpts.C11)
1132 .Case(
"c_static_assert", LangOpts.C11)
1133 .Case(
"c_thread_local",
1136 .Case(
"cxx_access_control_sfinae", LangOpts.CPlusPlus11)
1137 .Case(
"cxx_alias_templates", LangOpts.CPlusPlus11)
1138 .Case(
"cxx_alignas", LangOpts.CPlusPlus11)
1139 .Case(
"cxx_alignof", LangOpts.CPlusPlus11)
1140 .Case(
"cxx_atomic", LangOpts.CPlusPlus11)
1141 .Case(
"cxx_attributes", LangOpts.CPlusPlus11)
1142 .Case(
"cxx_auto_type", LangOpts.CPlusPlus11)
1143 .Case(
"cxx_constexpr", LangOpts.CPlusPlus11)
1144 .Case(
"cxx_decltype", LangOpts.CPlusPlus11)
1145 .Case(
"cxx_decltype_incomplete_return_types", LangOpts.CPlusPlus11)
1146 .Case(
"cxx_default_function_template_args", LangOpts.CPlusPlus11)
1147 .Case(
"cxx_defaulted_functions", LangOpts.CPlusPlus11)
1148 .Case(
"cxx_delegating_constructors", LangOpts.CPlusPlus11)
1149 .Case(
"cxx_deleted_functions", LangOpts.CPlusPlus11)
1150 .Case(
"cxx_explicit_conversions", LangOpts.CPlusPlus11)
1151 .Case(
"cxx_generalized_initializers", LangOpts.CPlusPlus11)
1152 .Case(
"cxx_implicit_moves", LangOpts.CPlusPlus11)
1153 .Case(
"cxx_inheriting_constructors", LangOpts.CPlusPlus11)
1154 .Case(
"cxx_inline_namespaces", LangOpts.CPlusPlus11)
1155 .Case(
"cxx_lambdas", LangOpts.CPlusPlus11)
1156 .Case(
"cxx_local_type_template_args", LangOpts.CPlusPlus11)
1157 .Case(
"cxx_nonstatic_member_init", LangOpts.CPlusPlus11)
1158 .Case(
"cxx_noexcept", LangOpts.CPlusPlus11)
1159 .Case(
"cxx_nullptr", LangOpts.CPlusPlus11)
1160 .Case(
"cxx_override_control", LangOpts.CPlusPlus11)
1161 .Case(
"cxx_range_for", LangOpts.CPlusPlus11)
1162 .Case(
"cxx_raw_string_literals", LangOpts.CPlusPlus11)
1163 .Case(
"cxx_reference_qualified_functions", LangOpts.CPlusPlus11)
1164 .Case(
"cxx_rvalue_references", LangOpts.CPlusPlus11)
1165 .Case(
"cxx_strong_enums", LangOpts.CPlusPlus11)
1166 .Case(
"cxx_static_assert", LangOpts.CPlusPlus11)
1167 .Case(
"cxx_thread_local",
1169 .Case(
"cxx_trailing_return", LangOpts.CPlusPlus11)
1170 .Case(
"cxx_unicode_literals", LangOpts.CPlusPlus11)
1171 .Case(
"cxx_unrestricted_unions", LangOpts.CPlusPlus11)
1172 .Case(
"cxx_user_literals", LangOpts.CPlusPlus11)
1173 .Case(
"cxx_variadic_templates", LangOpts.CPlusPlus11)
1175 .Case(
"cxx_aggregate_nsdmi", LangOpts.CPlusPlus14)
1176 .Case(
"cxx_binary_literals", LangOpts.CPlusPlus14)
1177 .Case(
"cxx_contextual_conversions", LangOpts.CPlusPlus14)
1178 .Case(
"cxx_decltype_auto", LangOpts.CPlusPlus14)
1179 .Case(
"cxx_generic_lambdas", LangOpts.CPlusPlus14)
1180 .Case(
"cxx_init_captures", LangOpts.CPlusPlus14)
1181 .Case(
"cxx_relaxed_constexpr", LangOpts.CPlusPlus14)
1182 .Case(
"cxx_return_type_deduction", LangOpts.CPlusPlus14)
1183 .Case(
"cxx_variable_templates", LangOpts.CPlusPlus14)
1192 .Case(
"has_nothrow_assign", LangOpts.CPlusPlus)
1193 .Case(
"has_nothrow_copy", LangOpts.CPlusPlus)
1194 .Case(
"has_nothrow_constructor", LangOpts.CPlusPlus)
1195 .Case(
"has_trivial_assign", LangOpts.CPlusPlus)
1196 .Case(
"has_trivial_copy", LangOpts.CPlusPlus)
1197 .Case(
"has_trivial_constructor", LangOpts.CPlusPlus)
1198 .Case(
"has_trivial_destructor", LangOpts.CPlusPlus)
1199 .Case(
"has_virtual_destructor", LangOpts.CPlusPlus)
1200 .Case(
"is_abstract", LangOpts.CPlusPlus)
1201 .Case(
"is_base_of", LangOpts.CPlusPlus)
1202 .Case(
"is_class", LangOpts.CPlusPlus)
1203 .Case(
"is_constructible", LangOpts.CPlusPlus)
1204 .Case(
"is_convertible_to", LangOpts.CPlusPlus)
1205 .Case(
"is_empty", LangOpts.CPlusPlus)
1206 .Case(
"is_enum", LangOpts.CPlusPlus)
1207 .Case(
"is_final", LangOpts.CPlusPlus)
1208 .Case(
"is_literal", LangOpts.CPlusPlus)
1209 .Case(
"is_standard_layout", LangOpts.CPlusPlus)
1210 .Case(
"is_pod", LangOpts.CPlusPlus)
1211 .Case(
"is_polymorphic", LangOpts.CPlusPlus)
1212 .Case(
"is_sealed", LangOpts.CPlusPlus && LangOpts.MicrosoftExt)
1213 .Case(
"is_trivial", LangOpts.CPlusPlus)
1214 .Case(
"is_trivially_assignable", LangOpts.CPlusPlus)
1215 .Case(
"is_trivially_constructible", LangOpts.CPlusPlus)
1216 .Case(
"is_trivially_copyable", LangOpts.CPlusPlus)
1217 .Case(
"is_union", LangOpts.CPlusPlus)
1218 .Case(
"modules", LangOpts.Modules)
1219 .Case(
"safe_stack", LangOpts.
Sanitize.
has(SanitizerKind::SafeStack))
1221 .Case(
"underlying_type", LangOpts.CPlusPlus)
1241 if (Extension.startswith(
"__") && Extension.endswith(
"__") &&
1242 Extension.size() >= 4)
1243 Extension = Extension.substr(2, Extension.size() - 4);
1247 return llvm::StringSwitch<bool>(Extension)
1249 .Case(
"c_alignas",
true)
1250 .Case(
"c_alignof",
true)
1251 .Case(
"c_atomic",
true)
1252 .Case(
"c_generic_selections",
true)
1253 .Case(
"c_static_assert",
true)
1256 .Case(
"cxx_atomic", LangOpts.CPlusPlus)
1257 .Case(
"cxx_deleted_functions", LangOpts.CPlusPlus)
1258 .Case(
"cxx_explicit_conversions", LangOpts.CPlusPlus)
1259 .Case(
"cxx_inline_namespaces", LangOpts.CPlusPlus)
1260 .Case(
"cxx_local_type_template_args", LangOpts.CPlusPlus)
1261 .Case(
"cxx_nonstatic_member_init", LangOpts.CPlusPlus)
1262 .Case(
"cxx_override_control", LangOpts.CPlusPlus)
1263 .Case(
"cxx_range_for", LangOpts.CPlusPlus)
1264 .Case(
"cxx_reference_qualified_functions", LangOpts.CPlusPlus)
1265 .Case(
"cxx_rvalue_references", LangOpts.CPlusPlus)
1266 .Case(
"cxx_variadic_templates", LangOpts.CPlusPlus)
1268 .Case(
"cxx_binary_literals",
true)
1269 .Case(
"cxx_init_captures", LangOpts.CPlusPlus11)
1270 .Case(
"cxx_variable_templates", LangOpts.CPlusPlus)
1287 PP.
Diag(LParenLoc, diag::err_pp_directive_required) << II->
getName();
1289 assert(Tok.
is(tok::identifier));
1298 if (Tok.
isNot(tok::l_paren)) {
1301 PP.
Diag(LParenLoc, diag::err_pp_expected_after) << II << tok::l_paren;
1304 if (!Tok.
is(tok::angle_string_literal) && !Tok.
is(tok::string_literal) &&
1331 case tok::angle_string_literal:
1332 case tok::string_literal: {
1333 bool Invalid =
false;
1334 Filename = PP.
getSpelling(Tok, FilenameBuffer, &Invalid);
1343 FilenameBuffer.push_back(
'<');
1349 Filename = FilenameBuffer;
1362 if (Tok.
isNot(tok::r_paren)) {
1364 << II << tok::r_paren;
1365 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1372 if (Filename.empty())
1378 PP.
LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, LookupFromFile,
1379 CurDir,
nullptr,
nullptr,
nullptr);
1382 return File !=
nullptr;
1402 const FileEntry *LookupFromFile =
nullptr;
1405 PP.
Diag(Tok, diag::pp_include_next_in_primary);
1412 }
else if (!Lookup) {
1413 PP.
Diag(Tok, diag::pp_include_next_absolute_path);
1429 bool &HasLexedNextTok)> Op) {
1432 if (Tok.
isNot(tok::l_paren)) {
1439 Tok.
setKind(tok::numeric_constant);
1444 unsigned ParenDepth = 1;
1449 bool SuppressDiagnostic =
false;
1464 if (!SuppressDiagnostic) {
1466 SuppressDiagnostic =
true;
1472 if (Result.hasValue())
1474 if (!SuppressDiagnostic) {
1476 SuppressDiagnostic =
true;
1481 if (--ParenDepth > 0)
1486 if (Result.hasValue())
1487 OS << Result.getValue();
1490 if (!SuppressDiagnostic)
1493 Tok.
setKind(tok::numeric_constant);
1498 if (Result.hasValue())
1501 bool HasLexedNextToken =
false;
1502 Result = Op(Tok, HasLexedNextToken);
1504 if (HasLexedNextToken)
1511 if (!SuppressDiagnostic) {
1519 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1520 SuppressDiagnostic =
true;
1540 void Preprocessor::ExpandBuiltinMacro(
Token &Tok) {
1543 assert(II &&
"Can't be a macro without id info!");
1547 if (II == Ident_Pragma)
1548 return Handle_Pragma(Tok);
1549 else if (II == Ident__pragma)
1550 return HandleMicrosoft__pragma(Tok);
1552 ++NumBuiltinMacroExpanded;
1555 llvm::raw_svector_ostream OS(TmpBuffer);
1561 if (II == Ident__LINE__) {
1581 Tok.
setKind(tok::numeric_constant);
1582 }
else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
1589 if (II == Ident__BASE_FILE__ && PLoc.
isValid()) {
1605 OS <<
'"' << FN <<
'"';
1607 Tok.
setKind(tok::string_literal);
1608 }
else if (II == Ident__DATE__) {
1612 Tok.
setKind(tok::string_literal);
1613 Tok.
setLength(strlen(
"\"Mmm dd yyyy\""));
1618 }
else if (II == Ident__TIME__) {
1622 Tok.
setKind(tok::string_literal);
1628 }
else if (II == Ident__INCLUDE_LEVEL__) {
1642 Tok.
setKind(tok::numeric_constant);
1643 }
else if (II == Ident__TIMESTAMP__) {
1658 time_t TT = CurFile->getModificationTime();
1659 struct tm *TM = localtime(&TT);
1660 Result = asctime(TM);
1662 Result =
"??? ??? ?? ??:??:?? ????\n";
1665 OS <<
'"' << StringRef(Result).drop_back() <<
'"';
1666 Tok.
setKind(tok::string_literal);
1667 }
else if (II == Ident__COUNTER__) {
1669 OS << CounterValue++;
1670 Tok.
setKind(tok::numeric_constant);
1671 }
else if (II == Ident__has_feature) {
1673 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1675 diag::err_feature_check_malformed);
1678 }
else if (II == Ident__has_extension) {
1680 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1682 diag::err_feature_check_malformed);
1685 }
else if (II == Ident__has_builtin) {
1687 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1689 diag::err_feature_check_malformed);
1696 return llvm::StringSwitch<bool>(II->
getName())
1697 .Case(
"__make_integer_seq", LangOpts.CPlusPlus)
1698 .Case(
"__type_pack_element", LangOpts.CPlusPlus)
1702 }
else if (II == Ident__is_identifier) {
1704 [](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1705 return Tok.
is(tok::identifier);
1707 }
else if (II == Ident__has_attribute) {
1709 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1711 diag::err_feature_check_malformed);
1715 }
else if (II == Ident__has_declspec) {
1717 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1719 diag::err_feature_check_malformed);
1723 }
else if (II == Ident__has_cpp_attribute) {
1725 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1728 diag::err_feature_check_malformed);
1735 if (Tok.
isNot(tok::coloncolon))
1736 HasLexedNextToken =
true;
1741 diag::err_feature_check_malformed);
1747 }
else if (II == Ident__has_include ||
1748 II == Ident__has_include_next) {
1753 if (II == Ident__has_include)
1758 if (Tok.
isNot(tok::r_paren))
1761 Tok.
setKind(tok::numeric_constant);
1762 }
else if (II == Ident__has_warning) {
1765 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1766 std::string WarningName;
1769 HasLexedNextToken = Tok.
is(tok::string_literal);
1776 if (WarningName.size() < 3 || WarningName[0] !=
'-' ||
1777 WarningName[1] !=
'W') {
1778 Diag(StrStartLoc, diag::warn_has_warning_invalid_option);
1789 WarningName.substr(2), Diags);
1791 }
else if (II == Ident__building_module) {
1796 [
this](
Token &Tok,
bool &HasLexedNextToken) ->
int {
1798 diag::err_expected_id_building_module);
1802 }
else if (II == Ident__MODULE__) {
1808 }
else if (II == Ident__identifier) {
1814 if (Tok.
isNot(tok::l_paren)) {
1817 << II << tok::l_paren;
1840 if (RParen.
isNot(tok::r_paren)) {
1842 << Tok.
getKind() << tok::r_paren;
1843 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1847 llvm_unreachable(
"Unknown identifier!");
A diagnostic that indicates a problem or potential problem.
bool isAtStartOfLine() const
isAtStartOfLine - Return true if this token is at the start of a line.
static IdentifierInfo * RegisterBuiltinMacro(Preprocessor &PP, const char *Name)
RegisterBuiltinMacro - Register the specified identifier in the identifier table and mark it as a bui...
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static bool CheckMatchedBrackets(const SmallVectorImpl< Token > &Tokens)
CheckMatchedBrackets - Returns true if the braces and parentheses in the token vector are properly ne...
ExternalPreprocessorSource * getExternalSource() const
MacroInfo * AllocateMacroInfo(SourceLocation L)
Allocate a new MacroInfo object with the provided SourceLocation.
bool ConcatenateIncludeName(SmallString< 128 > &FilenameBuffer, SourceLocation &End)
Handle cases where the #include name is expanded from a macro as multiple tokens, which need to be gl...
void setChangedSinceDeserialization()
Note that this identifier has changed since it was loaded from an AST file.
void markMacroAsUsed(MacroInfo *MI)
A macro is used, update information about macros that need unused warnings.
void setFlagValue(TokenFlags Flag, bool Val)
Set a flag to either true or false.
Defines the clang::FileManager interface and associated types.
Module * getCurrentSubmodule() const
Return the submodule owning the file being lexed.
bool isInvalid() const
Return true if this object is invalid or uninitialized.
SanitizerSet Sanitize
Set of enabled sanitizers.
Defines the SourceManager interface.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
void dumpMacroInfo(const IdentifierInfo *II)
Is the identifier known as a __declspec-style attribute?
bool isObjectLike() const
bool hasCommaPasting() const
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
static bool EvaluateHasIncludeCommon(Token &Tok, IdentifierInfo *II, Preprocessor &PP, const DirectoryLookup *LookupFrom, const FileEntry *LookupFromFile)
EvaluateHasIncludeCommon - Process a '__has_include("path")' or '__has_include_next("path")' expr...
Defines the clang::MacroInfo and clang::MacroDirective classes.
bool hasLeadingSpace() const
Return true if this token has whitespace before it.
Is the identifier known as a GNU-style attribute?
A description of the current definition of a macro.
static bool GenerateNewArgTokens(Preprocessor &PP, SmallVectorImpl< Token > &OldTokens, SmallVectorImpl< Token > &NewTokens, unsigned &NumArgs, SmallVectorImpl< SourceRange > &ParenHints, SmallVectorImpl< SourceRange > &InitLists)
GenerateNewArgTokens - Returns true if OldTokens can be converted to a new vector of tokens in NewTok...
void setFlag(TokenFlags Flag)
Set the specified flag.
SourceLocation getDefinitionLoc() const
Return the location that the macro was defined at.
bool isInPrimaryFile() const
Return true if we're in the top-level file, not in a #include.
StringRef getSpelling(SourceLocation loc, SmallVectorImpl< char > &buffer, bool *invalid=nullptr) const
Return the 'spelling' of the token at the given location; does not go up to the spelling location or ...
void Profile(llvm::FoldingSetNodeID &ID) const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
DefMacroDirective * appendDefMacroDirective(IdentifierInfo *II, MacroInfo *MI, SourceLocation Loc)
One of these records is kept for each identifier that is lexed.
Represents a macro directive exported by a module.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
bool isEnabled() const
Return true if this macro is enabled.
bool isFromAST() const
Return true if the identifier in its current state was loaded from an AST file.
std::pair< SourceLocation, SourceLocation > getExpansionRange(SourceLocation Loc) const
Given a SourceLocation object, return the range of tokens covered by the expansion in the ultimate fi...
static bool HasFeature(const Preprocessor &PP, StringRef Feature)
HasFeature - Return true if we recognize and implement the feature specified by the identifier as a s...
void setHasMacroDefinition(bool Val)
static bool getDiagnosticsInGroup(diag::Flavor Flavor, const WarningOption *Group, SmallVectorImpl< diag::kind > &Diags)
Return true if any diagnostics were found in this group, even if they were filtered out due to having...
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
const LangOptions & getLangOpts() const
Token - This structure provides full information about a lexed token.
bool isWarnIfUnused() const
Return true if we should emit a warning if the macro is unused.
void setKind(tok::TokenKind K)
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Describes a module or submodule.
MacroInfo * getMacroInfo() const
Get the MacroInfo that should be used for this definition.
bool isParsingIfOrElifDirective() const
True if we are currently preprocessing a if or #elif directive.
static void ComputeDATE_TIME(SourceLocation &DATELoc, SourceLocation &TIMELoc, Preprocessor &PP)
ComputeDATE_TIME - Compute the current time, enter it into the specified scratch buffer, then return DATELoc/TIMELoc locations with the position of the identifier tokens inserted.
static IdentifierInfo * ExpectFeatureIdentifierInfo(Token &Tok, Preprocessor &PP, signed DiagID)
Helper function to return the IdentifierInfo structure of a Token or generate a diagnostic if none av...
static ModuleMacro * create(Preprocessor &PP, Module *OwningModule, IdentifierInfo *II, MacroInfo *Macro, ArrayRef< ModuleMacro * > Overrides)
static void EvaluateFeatureLikeBuiltinMacro(llvm::raw_svector_ostream &OS, Token &Tok, IdentifierInfo *II, Preprocessor &PP, llvm::function_ref< int(Token &Tok, bool &HasLexedNextTok)> Op)
Process single-argument builtin feature-like macros that return integer values.
void LexNonComment(Token &Result)
Lex a token.
tok::TokenKind getTokenID() const
If this is a source-language token (e.g.
bool isOutOfDate() const
Determine whether the information for this identifier is out of date with respect to the external sou...
void ExpandedMacro()
ExpandedMacro - When a macro is expanded with this lexer as the current buffer, this method is called...
static bool EvaluateHasInclude(Token &Tok, IdentifierInfo *II, Preprocessor &PP)
EvaluateHasInclude - Process a '__has_include("path")' expression.
void destroy(Preprocessor &PP)
destroy - Destroy and deallocate the memory for this object.
TokenLexer - This implements a lexer that returns tokens from a macro body or token stream instead of...
Present this diagnostic as an error.
SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Char) const
Given a location that specifies the start of a token, return a new location that specifies a characte...
void setLoadedMacroDirective(IdentifierInfo *II, MacroDirective *MD)
Set a MacroDirective that was loaded from a PCH file.
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
const IntrusiveRefCntPtr< DiagnosticIDs > & getDiagnosticIDs() const
tok::TokenKind getKind() const
const TargetInfo & getTargetInfo() const
unsigned getLine() const
Return the presumed line number of this location.
const FileEntry * getFileEntry() const
getFileEntry - Return the FileEntry corresponding to this FileID.
detail::InMemoryDirectory::const_iterator I
DiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID) const
Forwarding function for diagnostics.
SourceLocation getIncludeLoc() const
Return the presumed include location of this location.
void appendMacroDirective(IdentifierInfo *II, MacroDirective *MD)
Add a directive to the macro directive history for this identifier.
void LexUnexpandedToken(Token &Result)
Just like Lex, but disables macro expansion of identifier tokens.
diag::Severity getExtensionHandlingBehavior() const
A little helper class used to produce diagnostics.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
std::string CurrentModule
The name of the current module, of which the main source file is a part.
bool hasWeakClassImport() const
Does this runtime support weakly importing classes?
ModuleMacro * addModuleMacro(Module *Mod, IdentifierInfo *II, MacroInfo *Macro, ArrayRef< ModuleMacro * > Overrides, bool &IsNew)
Register an exported macro for a module and identifier.
StringRef getName() const
Return the actual identifier string.
MacroArgs - An instance of this class captures information about the formal arguments specified to a ...
unsigned getNumArgs() const
Defines the clang::Preprocessor interface.
MultipleIncludeOpt MIOpt
A state machine that detects the #ifndef-wrapping a file idiom for the multiple-include optimization...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isNot(tok::TokenKind K) const
unsigned getNumTokens() const
Return the number of tokens that this macro expands to.
clang::ObjCRuntime ObjCRuntime
Represents an unpacked "presumed" location which can be presented to the user.
arg_iterator arg_end() const
SourceLocation createExpansionLoc(SourceLocation Loc, SourceLocation ExpansionLocStart, SourceLocation ExpansionLocEnd, unsigned TokLength, int LoadedID=0, unsigned LoadedOffset=0)
Return a new SourceLocation that encodes the fact that a token from SpellingLoc should actually be re...
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
The result type of a method or function.
static bool HasExtension(const Preprocessor &PP, StringRef Extension)
HasExtension - Return true if we recognize and implement the feature specified by the identifier...
DirectoryLookup - This class represents one entry in the search list that specifies the search order ...
const DirectoryLookup * GetCurDirLookup()
Get the DirectoryLookup structure used to find the current FileEntry, if CurLexer is non-null and if ...
void setIsUsed(bool Val)
Set the value of the IsUsed flag.
Encapsulates changes to the "macros namespace" (the location where the macro name became active...
bool isNonFragile() const
Does this runtime follow the set of implied behaviors for a "non-fragile" ABI?
bool hasOneOf(SanitizerMask K) const
Check if one or more sanitizers are enabled.
const char * getFilename() const
Return the presumed filename of this location.
Encodes a location in the source.
const char * getNameStart() const
Return the beginning of the actual null-terminated string for this identifier.
static bool isTrivialSingleTokenExpansion(const MacroInfo *MI, const IdentifierInfo *MacroIdent, Preprocessor &PP)
isTrivialSingleTokenExpansion - Return true if MI, which has a single token in its expansion...
PreprocessorLexer * getCurrentLexer() const
Return the current lexer being lexed from.
void setLength(unsigned Len)
bool isValid() const
Return true if this is a valid SourceLocation object.
static bool EvaluateHasIncludeNext(Token &Tok, IdentifierInfo *II, Preprocessor &PP)
EvaluateHasIncludeNext - Process '__has_include_next("path")' expression.
Cached information about one file (either on disk or in the virtual file system). ...
void forAllDefinitions(Fn F) const
void setIdentifierInfo(IdentifierInfo *II)
void setIsBuiltinMacro(bool Val=true)
Set or clear the isBuiltinMacro flag.
void Lex(Token &Result)
Lex the next token for this preprocessor.
ArrayRef< FormatToken * > Tokens
void EnterMacro(Token &Identifier, SourceLocation ILEnd, MacroInfo *Macro, MacroArgs *Args)
Add a Macro to the top of the include stack and start lexing tokens from it instead of the current bu...
bool isAmbiguous() const
true if the definition is ambiguous, false otherwise.
const Token & getReplacementToken(unsigned Tok) const
bool is(tok::TokenKind K) const
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
DiagnosticsEngine & getDiagnostics() const
unsigned getFlags() const
Return the internal represtation of the flags.
detail::InMemoryDirectory::const_iterator E
PreprocessorLexer * getCurrentFileLexer() const
Return the current file lexer being lexed from.
bool isFunctionLike() const
Encapsulates the data about a macro definition (e.g.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
bool GetIncludeFilenameSpelling(SourceLocation Loc, StringRef &Filename)
Turn the specified lexer token into a fully checked and spelled filename, e.g.
bool FinishLexStringLiteral(Token &Result, std::string &String, const char *DiagnosticTag, bool AllowMacroExpansion)
Complete the lexing of a string literal where the first token has already been lexed (see LexStringLi...
MacroDirective * getLocalMacroDirectiveHistory(const IdentifierInfo *II) const
Given an identifier, return the latest non-imported macro directive for that identifier.
virtual void updateOutOfDateIdentifier(IdentifierInfo &II)=0
Update an out-of-date identifier.
void CreateString(StringRef Str, Token &Tok, SourceLocation ExpansionLocStart=SourceLocation(), SourceLocation ExpansionLocEnd=SourceLocation())
Plop the specified string into a scratch buffer and set the specified token's location and length to ...
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.
bool isBuiltinMacro() const
Return true if this macro requires processing before expansion.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void LexIncludeFilename(Token &Result)
After the preprocessor has parsed a #include, lex and (potentially) macro expand the filename...
bool isTLSSupported() const
Whether the target supports thread-local storage.
const FileEntry * LookupFile(SourceLocation FilenameLoc, StringRef Filename, bool isAngled, const DirectoryLookup *FromDir, const FileEntry *FromFile, const DirectoryLookup *&CurDir, SmallVectorImpl< char > *SearchPath, SmallVectorImpl< char > *RelativePath, ModuleMap::KnownHeader *SuggestedModule, bool SkipCache=false)
Given a "foo" or <foo> reference, look up the indicated file.
ModuleMacro * getModuleMacro(Module *Mod, IdentifierInfo *II)
static MacroArgs * create(const MacroInfo *MI, ArrayRef< Token > UnexpArgTokens, bool VarargsElided, Preprocessor &PP)
MacroArgs ctor function - Create a new MacroArgs object with the specified macro and argument info...
Defines the clang::TargetInfo interface.
void setPrevious(MacroDirective *Prev)
Set previous definition of the macro with the same name.
unsigned getLength() const
void setLocation(SourceLocation L)
bool hadMacroDefinition() const
Returns true if this identifier was #defined to some value at any moment.
arg_iterator arg_begin() const
A trivial tuple used to represent a source range.
void clearFlag(TokenFlags Flag)
Unset the specified flag.
virtual void CodeCompleteMacroArgument(IdentifierInfo *Macro, MacroInfo *MacroInfo, unsigned ArgumentIndex)
Callback invoked when performing code completion inside a function-like macro argument.
bool isAnnotation() const
Return true if this is any of tok::annot_* kind tokens.
void startToken()
Reset all flags to cleared.
const MacroDirective * getPrevious() const
Get previous definition of the macro with the same name.
static std::string Stringify(StringRef Str, bool Charify=false)
Stringify - Convert the specified string into a C string by escaping '\' and " characters. This does not add surrounding ""'s to the string.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isUsed() const
Return false if this macro is defined in the main file and has not yet been used. ...
IdentifierInfo * getIdentifierInfo() const
PresumedLoc getPresumedLoc(SourceLocation Loc, bool UseLineDirectives=true) const
Returns the "presumed" location of a SourceLocation specifies.