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);
57 if (!MD->
isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
66 MacroState &StoredMD = CurSubmoduleState->Macros[II];
67 assert(!StoredMD.getLatest() &&
68 "the macro history was modified before initializing it from a pch");
72 if (!MD->
isDefined() && LeafModuleMacros.find(II) == LeafModuleMacros.end())
80 llvm::FoldingSetNodeID
ID;
84 if (
auto *MM = ModuleMacros.FindNodeOrInsertPos(ID, InsertPos)) {
90 ModuleMacros.InsertNode(MM, InsertPos);
94 for (
auto *O : Overrides) {
95 HidAny |= (O->NumOverriddenBy == 0);
100 auto &LeafMacros = LeafModuleMacros[II];
102 LeafMacros.erase(std::remove_if(LeafMacros.begin(), LeafMacros.end(),
104 return MM->NumOverriddenBy != 0;
110 LeafMacros.push_back(MM);
119 llvm::FoldingSetNodeID
ID;
123 return ModuleMacros.FindNodeOrInsertPos(ID, InsertPos);
126 void Preprocessor::updateModuleMacroInfo(
const IdentifierInfo *II,
127 ModuleMacroInfo &Info) {
128 assert(Info.ActiveModuleMacrosGeneration !=
129 CurSubmoduleState->VisibleModules.getGeneration() &&
130 "don't need to update this macro name info");
131 Info.ActiveModuleMacrosGeneration =
132 CurSubmoduleState->VisibleModules.getGeneration();
134 auto Leaf = LeafModuleMacros.find(II);
135 if (Leaf == LeafModuleMacros.end()) {
140 Info.ActiveModuleMacros.clear();
143 llvm::DenseMap<ModuleMacro *, int> NumHiddenOverrides;
144 for (
auto *O : Info.OverriddenMacros)
145 NumHiddenOverrides[O] = -1;
149 for (
auto *LeafMM : Leaf->second) {
150 assert(LeafMM->getNumOverridingMacros() == 0 &&
"leaf macro overridden");
151 if (NumHiddenOverrides.lookup(LeafMM) == 0)
152 Worklist.push_back(LeafMM);
154 while (!Worklist.empty()) {
155 auto *MM = Worklist.pop_back_val();
156 if (CurSubmoduleState->VisibleModules.isVisible(MM->getOwningModule())) {
159 if (MM->getMacroInfo())
160 Info.ActiveModuleMacros.push_back(MM);
162 for (
auto *O : MM->overrides())
163 if ((
unsigned)++NumHiddenOverrides[O] == O->getNumOverridingMacros())
164 Worklist.push_back(O);
168 std::reverse(Info.ActiveModuleMacros.begin(), Info.ActiveModuleMacros.end());
172 bool IsSystemMacro =
true;
173 bool IsAmbiguous =
false;
174 if (
auto *MD = Info.MD) {
175 while (MD && isa<VisibilityMacroDirective>(MD))
176 MD = MD->getPrevious();
177 if (
auto *DMD = dyn_cast_or_null<DefMacroDirective>(MD)) {
182 for (
auto *Active : Info.ActiveModuleMacros) {
183 auto *NewMI = Active->getMacroInfo();
194 if (MI && NewMI != MI &&
195 !MI->isIdenticalTo(*NewMI, *
this,
true))
197 IsSystemMacro &= Active->getOwningModule()->IsSystem ||
201 Info.IsAmbiguous = IsAmbiguous && !IsSystemMacro;
206 auto LeafIt = LeafModuleMacros.find(II);
207 if (LeafIt != LeafModuleMacros.end())
208 Leaf = LeafIt->second;
209 const MacroState *
State =
nullptr;
210 auto Pos = CurSubmoduleState->Macros.find(II);
211 if (Pos != CurSubmoduleState->Macros.end())
212 State = &Pos->second;
216 llvm::errs() <<
" ambiguous";
217 if (
State && !
State->getOverriddenMacros().empty()) {
218 llvm::errs() <<
" overrides";
219 for (
auto *O :
State->getOverriddenMacros())
220 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
222 llvm::errs() <<
"\n";
225 for (
auto *MD =
State ?
State->getLatest() :
nullptr; MD;
226 MD = MD->getPrevious()) {
233 for (
auto *MM :
State ?
State->getActiveModuleMacros(*
this, II) :
None)
237 while (!Worklist.empty()) {
238 auto *MM = Worklist.pop_back_val();
239 llvm::errs() <<
" ModuleMacro " << MM <<
" "
240 << MM->getOwningModule()->getFullModuleName();
241 if (!MM->getMacroInfo())
242 llvm::errs() <<
" undef";
244 if (Active.count(MM))
245 llvm::errs() <<
" active";
246 else if (!CurSubmoduleState->VisibleModules.isVisible(
247 MM->getOwningModule()))
248 llvm::errs() <<
" hidden";
249 else if (MM->getMacroInfo())
250 llvm::errs() <<
" overridden";
252 if (!MM->overrides().empty()) {
253 llvm::errs() <<
" overrides";
254 for (
auto *O : MM->overrides()) {
255 llvm::errs() <<
" " << O->getOwningModule()->getFullModuleName();
256 if (Visited.insert(O).second)
257 Worklist.push_back(O);
260 llvm::errs() <<
"\n";
261 if (
auto *MI = MM->getMacroInfo()) {
264 llvm::errs() <<
"\n";
285 void Preprocessor::RegisterBuiltinMacros() {
294 if (LangOpts.CPlusPlus)
295 Ident__has_cpp_attribute =
298 Ident__has_cpp_attribute =
nullptr;
306 if (LangOpts.MicrosoftExt) {
310 Ident__identifier =
nullptr;
311 Ident__pragma =
nullptr;
326 if (LangOpts.Modules) {
333 Ident__MODULE__ =
nullptr;
335 Ident__building_module =
nullptr;
336 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;
729 unsigned NumActuals = 0;
730 while (Tok.
isNot(tok::r_paren)) {
734 assert(Tok.
isOneOf(tok::l_paren, tok::comma) &&
735 "only expect argument separators here");
737 unsigned ArgTokenStart = ArgTokens.size();
742 unsigned NumParens = 0;
750 if (!ContainsCodeCompletionTok) {
751 Diag(MacroName, diag::err_unterm_macro_invoc);
764 }
else if (Tok.
is(tok::r_paren)) {
766 if (NumParens-- == 0) {
770 }
else if (Tok.
is(tok::l_paren)) {
772 }
else if (Tok.
is(tok::comma) && NumParens == 0 &&
781 if (!isVariadic)
break;
782 if (NumFixedArgsLeft > 1)
784 }
else if (Tok.
is(tok::comment) && !KeepMacroComments) {
798 }
else if (Tok.
is(tok::code_completion)) {
799 ContainsCodeCompletionTok =
true;
808 ArgTokens.push_back(Tok);
813 if (ArgTokens.empty() && Tok.
getKind() == tok::r_paren)
818 if (!isVariadic && NumFixedArgsLeft == 0 && TooManyArgsLoc.
isInvalid()) {
819 if (ArgTokens.size() != ArgTokenStart)
820 TooManyArgsLoc = ArgTokens[ArgTokenStart].getLocation();
822 TooManyArgsLoc = ArgStartLoc;
827 if (ArgTokens.size() == ArgTokenStart && !LangOpts.C99)
828 Diag(Tok, LangOpts.CPlusPlus11 ?
829 diag::warn_cxx98_compat_empty_fnmacro_arg :
830 diag::ext_empty_fnmacro_arg);
838 ArgTokens.push_back(EOFTok);
840 if (!ContainsCodeCompletionTok && NumFixedArgsLeft != 0)
850 if (!isVariadic && NumActuals > MinArgsExpected &&
851 !ContainsCodeCompletionTok) {
854 Diag(TooManyArgsLoc, diag::err_too_many_args_in_macro_invoc);
864 unsigned FixedNumArgs = 0;
867 ParenHints, InitLists)) {
868 if (!InitLists.empty()) {
871 diag::note_init_list_at_beginning_of_macro_argument);
877 if (FixedNumArgs != MinArgsExpected)
885 ArgTokens.swap(FixedArgTokens);
886 NumActuals = FixedNumArgs;
890 bool isVarargsElided =
false;
892 if (ContainsCodeCompletionTok) {
899 for (; NumActuals < MinArgsExpected; ++NumActuals)
900 ArgTokens.push_back(EOFTok);
903 if (NumActuals < MinArgsExpected) {
905 if (NumActuals == 0 && MinArgsExpected == 1) {
913 (NumActuals+1 == MinArgsExpected ||
914 (NumActuals == 0 && MinArgsExpected == 2))) {
922 Diag(Tok, diag::ext_missing_varargs_arg);
933 isVarargsElided =
true;
934 }
else if (!ContainsCodeCompletionTok) {
936 Diag(Tok, diag::err_too_few_args_in_macro_invoc);
948 ArgTokens.push_back(Tok);
951 if (NumActuals == 0 && MinArgsExpected == 2)
952 ArgTokens.push_back(Tok);
954 }
else if (NumActuals > MinArgsExpected && !MI->
isVariadic() &&
955 !ContainsCodeCompletionTok) {
958 Diag(MacroName, diag::err_too_many_args_in_macro_invoc);
978 size_t newIndex = MacroExpandedTokens.size();
979 bool cacheNeedsToGrow = tokens.size() >
980 MacroExpandedTokens.capacity()-MacroExpandedTokens.size();
981 MacroExpandedTokens.append(tokens.begin(), tokens.end());
983 if (cacheNeedsToGrow) {
986 for (
unsigned i = 0, e = MacroExpandingLexersStack.size(); i != e; ++i) {
989 std::tie(prevLexer, tokIndex) = MacroExpandingLexersStack[i];
990 prevLexer->Tokens = MacroExpandedTokens.data() + tokIndex;
994 MacroExpandingLexersStack.push_back(std::make_pair(tokLexer, newIndex));
995 return MacroExpandedTokens.data() + newIndex;
998 void Preprocessor::removeCachedMacroExpandedTokensOfLastLexer() {
999 assert(!MacroExpandingLexersStack.empty());
1000 size_t tokIndex = MacroExpandingLexersStack.back().second;
1001 assert(tokIndex < MacroExpandedTokens.size());
1003 MacroExpandedTokens.resize(tokIndex);
1004 MacroExpandingLexersStack.pop_back();
1012 time_t TT = time(
nullptr);
1013 struct tm *TM = localtime(&TT);
1015 static const char *
const Months[] = {
1016 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"
1021 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1022 TmpStream << llvm::format(
"\"%s %2d %4d\"", Months[TM->tm_mon],
1023 TM->tm_mday, TM->tm_year + 1900);
1032 llvm::raw_svector_ostream TmpStream(TmpBuffer);
1033 TmpStream << llvm::format(
"\"%02d:%02d:%02d\"",
1034 TM->tm_hour, TM->tm_min, TM->tm_sec);
1047 StringRef Feature = II->
getName();
1050 if (Feature.startswith(
"__") && Feature.endswith(
"__") && Feature.size() >= 4)
1051 Feature = Feature.substr(2, Feature.size() - 4);
1053 return llvm::StringSwitch<bool>(Feature)
1054 .Case(
"address_sanitizer",
1056 SanitizerKind::KernelAddress))
1057 .Case(
"assume_nonnull",
true)
1058 .Case(
"attribute_analyzer_noreturn",
true)
1059 .Case(
"attribute_availability",
true)
1060 .Case(
"attribute_availability_with_message",
true)
1061 .Case(
"attribute_availability_app_extension",
true)
1062 .Case(
"attribute_availability_with_version_underscores",
true)
1063 .Case(
"attribute_availability_tvos",
true)
1064 .Case(
"attribute_availability_watchos",
true)
1065 .Case(
"attribute_cf_returns_not_retained",
true)
1066 .Case(
"attribute_cf_returns_retained",
true)
1067 .Case(
"attribute_cf_returns_on_parameters",
true)
1068 .Case(
"attribute_deprecated_with_message",
true)
1069 .Case(
"attribute_ext_vector_type",
true)
1070 .Case(
"attribute_ns_returns_not_retained",
true)
1071 .Case(
"attribute_ns_returns_retained",
true)
1072 .Case(
"attribute_ns_consumes_self",
true)
1073 .Case(
"attribute_ns_consumed",
true)
1074 .Case(
"attribute_cf_consumed",
true)
1075 .Case(
"attribute_objc_ivar_unused",
true)
1076 .Case(
"attribute_objc_method_family",
true)
1077 .Case(
"attribute_overloadable",
true)
1078 .Case(
"attribute_unavailable_with_message",
true)
1079 .Case(
"attribute_unused_on_fields",
true)
1080 .Case(
"blocks", LangOpts.Blocks)
1081 .Case(
"c_thread_safety_attributes",
true)
1082 .Case(
"cxx_exceptions", LangOpts.CXXExceptions)
1083 .Case(
"cxx_rtti", LangOpts.RTTI && LangOpts.RTTIData)
1084 .Case(
"enumerator_attributes",
true)
1085 .Case(
"nullability",
true)
1086 .Case(
"memory_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::Memory))
1087 .Case(
"thread_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::Thread))
1088 .Case(
"dataflow_sanitizer", LangOpts.
Sanitize.
has(SanitizerKind::DataFlow))
1090 .Case(
"objc_arr", LangOpts.ObjCAutoRefCount)
1091 .Case(
"objc_arc", LangOpts.ObjCAutoRefCount)
1092 .Case(
"objc_arc_weak", LangOpts.ObjCWeak)
1093 .Case(
"objc_default_synthesize_properties", LangOpts.ObjC2)
1094 .Case(
"objc_fixed_enum", LangOpts.ObjC2)
1095 .Case(
"objc_instancetype", LangOpts.ObjC2)
1096 .Case(
"objc_kindof", LangOpts.ObjC2)
1097 .Case(
"objc_modules", LangOpts.ObjC2 && LangOpts.Modules)
1099 .Case(
"objc_property_explicit_atomic",
1101 .Case(
"objc_protocol_qualifier_mangling",
true)
1103 .Case(
"ownership_holds",
true)
1104 .Case(
"ownership_returns",
true)
1105 .Case(
"ownership_takes",
true)
1106 .Case(
"objc_bool",
true)
1108 .Case(
"objc_array_literals", LangOpts.ObjC2)
1109 .Case(
"objc_dictionary_literals", LangOpts.ObjC2)
1110 .Case(
"objc_boxed_expressions", LangOpts.ObjC2)
1111 .Case(
"objc_boxed_nsvalue_expressions", LangOpts.ObjC2)
1112 .Case(
"arc_cf_code_audited",
true)
1113 .Case(
"objc_bridge_id",
true)
1114 .Case(
"objc_bridge_id_on_typedefs",
true)
1115 .Case(
"objc_generics", LangOpts.ObjC2)
1116 .Case(
"objc_generics_variance", LangOpts.ObjC2)
1118 .Case(
"c_alignas", LangOpts.C11)
1119 .Case(
"c_alignof", LangOpts.C11)
1120 .Case(
"c_atomic", LangOpts.C11)
1121 .Case(
"c_generic_selections", LangOpts.C11)
1122 .Case(
"c_static_assert", LangOpts.C11)
1123 .Case(
"c_thread_local",
1126 .Case(
"cxx_access_control_sfinae", LangOpts.CPlusPlus11)
1127 .Case(
"cxx_alias_templates", LangOpts.CPlusPlus11)
1128 .Case(
"cxx_alignas", LangOpts.CPlusPlus11)
1129 .Case(
"cxx_alignof", LangOpts.CPlusPlus11)
1130 .Case(
"cxx_atomic", LangOpts.CPlusPlus11)
1131 .Case(
"cxx_attributes", LangOpts.CPlusPlus11)
1132 .Case(
"cxx_auto_type", LangOpts.CPlusPlus11)
1133 .Case(
"cxx_constexpr", LangOpts.CPlusPlus11)
1134 .Case(
"cxx_decltype", LangOpts.CPlusPlus11)
1135 .Case(
"cxx_decltype_incomplete_return_types", LangOpts.CPlusPlus11)
1136 .Case(
"cxx_default_function_template_args", LangOpts.CPlusPlus11)
1137 .Case(
"cxx_defaulted_functions", LangOpts.CPlusPlus11)
1138 .Case(
"cxx_delegating_constructors", LangOpts.CPlusPlus11)
1139 .Case(
"cxx_deleted_functions", LangOpts.CPlusPlus11)
1140 .Case(
"cxx_explicit_conversions", LangOpts.CPlusPlus11)
1141 .Case(
"cxx_generalized_initializers", LangOpts.CPlusPlus11)
1142 .Case(
"cxx_implicit_moves", LangOpts.CPlusPlus11)
1143 .Case(
"cxx_inheriting_constructors", LangOpts.CPlusPlus11)
1144 .Case(
"cxx_inline_namespaces", LangOpts.CPlusPlus11)
1145 .Case(
"cxx_lambdas", LangOpts.CPlusPlus11)
1146 .Case(
"cxx_local_type_template_args", LangOpts.CPlusPlus11)
1147 .Case(
"cxx_nonstatic_member_init", LangOpts.CPlusPlus11)
1148 .Case(
"cxx_noexcept", LangOpts.CPlusPlus11)
1149 .Case(
"cxx_nullptr", LangOpts.CPlusPlus11)
1150 .Case(
"cxx_override_control", LangOpts.CPlusPlus11)
1151 .Case(
"cxx_range_for", LangOpts.CPlusPlus11)
1152 .Case(
"cxx_raw_string_literals", LangOpts.CPlusPlus11)
1153 .Case(
"cxx_reference_qualified_functions", LangOpts.CPlusPlus11)
1154 .Case(
"cxx_rvalue_references", LangOpts.CPlusPlus11)
1155 .Case(
"cxx_strong_enums", LangOpts.CPlusPlus11)
1156 .Case(
"cxx_static_assert", LangOpts.CPlusPlus11)
1157 .Case(
"cxx_thread_local",
1159 .Case(
"cxx_trailing_return", LangOpts.CPlusPlus11)
1160 .Case(
"cxx_unicode_literals", LangOpts.CPlusPlus11)
1161 .Case(
"cxx_unrestricted_unions", LangOpts.CPlusPlus11)
1162 .Case(
"cxx_user_literals", LangOpts.CPlusPlus11)
1163 .Case(
"cxx_variadic_templates", LangOpts.CPlusPlus11)
1165 .Case(
"cxx_aggregate_nsdmi", LangOpts.CPlusPlus14)
1166 .Case(
"cxx_binary_literals", LangOpts.CPlusPlus14)
1167 .Case(
"cxx_contextual_conversions", LangOpts.CPlusPlus14)
1168 .Case(
"cxx_decltype_auto", LangOpts.CPlusPlus14)
1169 .Case(
"cxx_generic_lambdas", LangOpts.CPlusPlus14)
1170 .Case(
"cxx_init_captures", LangOpts.CPlusPlus14)
1171 .Case(
"cxx_relaxed_constexpr", LangOpts.CPlusPlus14)
1172 .Case(
"cxx_return_type_deduction", LangOpts.CPlusPlus14)
1173 .Case(
"cxx_variable_templates", LangOpts.CPlusPlus14)
1180 .Case(
"has_nothrow_assign", LangOpts.CPlusPlus)
1181 .Case(
"has_nothrow_copy", LangOpts.CPlusPlus)
1182 .Case(
"has_nothrow_constructor", LangOpts.CPlusPlus)
1183 .Case(
"has_trivial_assign", LangOpts.CPlusPlus)
1184 .Case(
"has_trivial_copy", LangOpts.CPlusPlus)
1185 .Case(
"has_trivial_constructor", LangOpts.CPlusPlus)
1186 .Case(
"has_trivial_destructor", LangOpts.CPlusPlus)
1187 .Case(
"has_virtual_destructor", LangOpts.CPlusPlus)
1188 .Case(
"is_abstract", LangOpts.CPlusPlus)
1189 .Case(
"is_base_of", LangOpts.CPlusPlus)
1190 .Case(
"is_class", LangOpts.CPlusPlus)
1191 .Case(
"is_constructible", LangOpts.CPlusPlus)
1192 .Case(
"is_convertible_to", LangOpts.CPlusPlus)
1193 .Case(
"is_empty", LangOpts.CPlusPlus)
1194 .Case(
"is_enum", LangOpts.CPlusPlus)
1195 .Case(
"is_final", LangOpts.CPlusPlus)
1196 .Case(
"is_literal", LangOpts.CPlusPlus)
1197 .Case(
"is_standard_layout", LangOpts.CPlusPlus)
1198 .Case(
"is_pod", LangOpts.CPlusPlus)
1199 .Case(
"is_polymorphic", LangOpts.CPlusPlus)
1200 .Case(
"is_sealed", LangOpts.MicrosoftExt)
1201 .Case(
"is_trivial", LangOpts.CPlusPlus)
1202 .Case(
"is_trivially_assignable", LangOpts.CPlusPlus)
1203 .Case(
"is_trivially_constructible", LangOpts.CPlusPlus)
1204 .Case(
"is_trivially_copyable", LangOpts.CPlusPlus)
1205 .Case(
"is_union", LangOpts.CPlusPlus)
1206 .Case(
"modules", LangOpts.Modules)
1207 .Case(
"safe_stack", LangOpts.
Sanitize.
has(SanitizerKind::SafeStack))
1209 .Case(
"underlying_type", LangOpts.CPlusPlus)
1227 StringRef Extension = II->
getName();
1230 if (Extension.startswith(
"__") && Extension.endswith(
"__") &&
1231 Extension.size() >= 4)
1232 Extension = Extension.substr(2, Extension.size() - 4);
1236 return llvm::StringSwitch<bool>(Extension)
1238 .Case(
"c_alignas",
true)
1239 .Case(
"c_alignof",
true)
1240 .Case(
"c_atomic",
true)
1241 .Case(
"c_generic_selections",
true)
1242 .Case(
"c_static_assert",
true)
1245 .Case(
"cxx_atomic", LangOpts.CPlusPlus)
1246 .Case(
"cxx_deleted_functions", LangOpts.CPlusPlus)
1247 .Case(
"cxx_explicit_conversions", LangOpts.CPlusPlus)
1248 .Case(
"cxx_inline_namespaces", LangOpts.CPlusPlus)
1249 .Case(
"cxx_local_type_template_args", LangOpts.CPlusPlus)
1250 .Case(
"cxx_nonstatic_member_init", LangOpts.CPlusPlus)
1251 .Case(
"cxx_override_control", LangOpts.CPlusPlus)
1252 .Case(
"cxx_range_for", LangOpts.CPlusPlus)
1253 .Case(
"cxx_reference_qualified_functions", LangOpts.CPlusPlus)
1254 .Case(
"cxx_rvalue_references", LangOpts.CPlusPlus)
1255 .Case(
"cxx_variadic_templates", LangOpts.CPlusPlus)
1257 .Case(
"cxx_binary_literals",
true)
1258 .Case(
"cxx_init_captures", LangOpts.CPlusPlus11)
1259 .Case(
"cxx_variable_templates", LangOpts.CPlusPlus)
1276 PP.
Diag(LParenLoc, diag::err_pp_directive_required) << II->
getName();
1278 assert(Tok.
is(tok::identifier));
1287 if (Tok.
isNot(tok::l_paren)) {
1290 PP.
Diag(LParenLoc, diag::err_pp_expected_after) << II << tok::l_paren;
1293 if (!Tok.
is(tok::angle_string_literal) && !Tok.
is(tok::string_literal) &&
1320 case tok::angle_string_literal:
1321 case tok::string_literal: {
1322 bool Invalid =
false;
1323 Filename = PP.
getSpelling(Tok, FilenameBuffer, &Invalid);
1332 FilenameBuffer.push_back(
'<');
1338 Filename = FilenameBuffer;
1351 if (Tok.
isNot(tok::r_paren)) {
1353 << II << tok::r_paren;
1354 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1361 if (Filename.empty())
1367 PP.
LookupFile(FilenameLoc, Filename, isAngled, LookupFrom, LookupFromFile,
1368 CurDir,
nullptr,
nullptr,
nullptr);
1371 return File !=
nullptr;
1391 const FileEntry *LookupFromFile =
nullptr;
1394 PP.
Diag(Tok, diag::pp_include_next_in_primary);
1401 }
else if (!Lookup) {
1402 PP.
Diag(Tok, diag::pp_include_next_absolute_path);
1419 if (Tok.
isNot(tok::l_paren)) {
1432 if (Tok.
isNot(tok::identifier)) {
1444 if (Tok.
isNot(tok::r_paren)) {
1447 PP.
Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1456 void Preprocessor::ExpandBuiltinMacro(
Token &Tok) {
1459 assert(II &&
"Can't be a macro without id info!");
1463 if (II == Ident_Pragma)
1464 return Handle_Pragma(Tok);
1465 else if (II == Ident__pragma)
1466 return HandleMicrosoft__pragma(Tok);
1468 ++NumBuiltinMacroExpanded;
1471 llvm::raw_svector_ostream OS(TmpBuffer);
1477 if (II == Ident__LINE__) {
1497 Tok.
setKind(tok::numeric_constant);
1498 }
else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
1505 if (II == Ident__BASE_FILE__ && PLoc.
isValid()) {
1521 OS <<
'"' << FN <<
'"';
1523 Tok.
setKind(tok::string_literal);
1524 }
else if (II == Ident__DATE__) {
1528 Tok.
setKind(tok::string_literal);
1529 Tok.
setLength(strlen(
"\"Mmm dd yyyy\""));
1534 }
else if (II == Ident__TIME__) {
1538 Tok.
setKind(tok::string_literal);
1544 }
else if (II == Ident__INCLUDE_LEVEL__) {
1558 Tok.
setKind(tok::numeric_constant);
1559 }
else if (II == Ident__TIMESTAMP__) {
1574 time_t TT = CurFile->getModificationTime();
1575 struct tm *TM = localtime(&TT);
1576 Result = asctime(TM);
1578 Result =
"??? ??? ?? ??:??:?? ????\n";
1581 OS <<
'"' << StringRef(Result).drop_back() <<
'"';
1582 Tok.
setKind(tok::string_literal);
1583 }
else if (II == Ident__COUNTER__) {
1585 OS << CounterValue++;
1586 Tok.
setKind(tok::numeric_constant);
1587 }
else if (II == Ident__has_feature ||
1588 II == Ident__has_extension ||
1589 II == Ident__has_builtin ||
1590 II == Ident__is_identifier ||
1591 II == Ident__has_attribute ||
1592 II == Ident__has_declspec ||
1593 II == Ident__has_cpp_attribute) {
1597 bool IsValid =
false;
1603 if (Tok.
is(tok::l_paren)) {
1610 bool IsScopeValid =
true;
1611 if (II == Ident__has_cpp_attribute && Tok.
is(tok::coloncolon)) {
1614 ScopeII = FeatureII;
1618 IsScopeValid =
false;
1621 if (IsScopeValid && Tok.
is(tok::r_paren))
1625 while (Tok.
isNot(tok::r_paren) && Tok.
isNot(tok::eod) &&
1632 Diag(StartLoc, diag::err_feature_check_malformed);
1633 else if (II == Ident__is_identifier)
1634 Value = FeatureII->
getTokenID() == tok::identifier;
1635 else if (II == Ident__has_builtin) {
1640 StringRef Feature = FeatureII->
getName();
1641 Value = llvm::StringSwitch<bool>(Feature)
1642 .Case(
"__make_integer_seq",
getLangOpts().CPlusPlus)
1645 }
else if (II == Ident__has_attribute)
1648 else if (II == Ident__has_cpp_attribute)
1651 else if (II == Ident__has_declspec)
1654 else if (II == Ident__has_extension)
1657 assert(II == Ident__has_feature &&
"Must be feature check");
1664 Tok.
setKind(tok::numeric_constant);
1665 }
else if (II == Ident__has_include ||
1666 II == Ident__has_include_next) {
1671 if (II == Ident__has_include)
1676 if (Tok.
isNot(tok::r_paren))
1679 Tok.
setKind(tok::numeric_constant);
1680 }
else if (II == Ident__has_warning) {
1684 bool IsValid =
false;
1689 if (Tok.
isNot(tok::l_paren)) {
1690 Diag(StartLoc, diag::err_warning_check_malformed);
1695 std::string WarningName;
1700 while (Tok.
isNot(tok::r_paren) && Tok.
isNot(tok::eod) &&
1707 if (!(IsValid = Tok.
is(tok::r_paren))) {
1708 Diag(StartLoc, diag::err_warning_check_malformed);
1714 if (WarningName.size() < 3 || WarningName[0] !=
'-' ||
1715 WarningName[1] !=
'W') {
1716 Diag(StrStartLoc, diag::warn_has_warning_invalid_option);
1727 WarningName.substr(2), Diags);
1733 Tok.
setKind(tok::numeric_constant);
1734 }
else if (II == Ident__building_module) {
1739 Tok.
setKind(tok::numeric_constant);
1740 }
else if (II == Ident__MODULE__) {
1746 }
else if (II == Ident__identifier) {
1752 if (Tok.
isNot(tok::l_paren)) {
1755 << II << tok::l_paren;
1778 if (RParen.
isNot(tok::r_paren)) {
1780 << Tok.
getKind() << tok::r_paren;
1781 Diag(LParenLoc, diag::note_matching) << tok::l_paren;
1785 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 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...
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 ModuleMacro * create(Preprocessor &PP, Module *OwningModule, IdentifierInfo *II, MacroInfo *Macro, ArrayRef< ModuleMacro * > Overrides)
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.
bool hasWeakClassImport() const
Does this runtime support weakly importing classes?
ID
Defines the set of possible language-specific address spaces.
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.
static bool EvaluateBuildingModule(Token &Tok, IdentifierInfo *II, Preprocessor &PP)
Process __building_module(identifier) expression.
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...
static bool HasFeature(const Preprocessor &PP, const IdentifierInfo *II)
HasFeature - Return true if we recognize and implement the feature specified by the identifier as a s...
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.
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 EnterTokenStream(const Token *Toks, unsigned NumToks, bool DisableMacroExpansion, bool OwnsTokens)
Add a "macro" context to the top of the include stack, which will cause the lexer to start returning ...
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.
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
static bool HasExtension(const Preprocessor &PP, const IdentifierInfo *II)
HasExtension - Return true if we recognize and implement the feature specified by the identifier...
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.