42 #include "llvm/ADT/DenseMap.h" 43 #include "llvm/ADT/SmallSet.h" 44 #include "llvm/Support/TimeProfiler.h" 46 using namespace clang;
58 std::string InventedName;
59 llvm::raw_string_ostream OS(InventedName);
62 OS <<
"auto:" << Index + 1;
64 OS << ParamName->
getName() <<
":auto";
78 Policy.
Bool = BoolMacro->isObjectLike() &&
79 BoolMacro->getNumTokens() == 1 &&
80 BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
100 void set(
Sema &S) { this->S = &S; }
106 FileID PrevFID)
override {
114 if (llvm::timeTraceProfilerEnabled()) {
116 llvm::timeTraceProfilerBegin(
117 "Source", FE !=
nullptr ? FE->
getName() : StringRef(
"<unknown>"));
120 IncludeStack.push_back(IncludeLoc);
127 if (!IncludeStack.empty()) {
128 if (llvm::timeTraceProfilerEnabled())
129 llvm::timeTraceProfilerEnd();
133 IncludeStack.pop_back_val());
147 : ExternalSource(nullptr), isMultiplexExternalSource(
false),
148 FPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
149 Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()),
150 SourceMgr(PP.getSourceManager()), CollectStats(
false),
151 CodeCompleter(CodeCompleter), CurContext(nullptr),
152 OriginalLexicalContext(nullptr), MSStructPragmaOn(
false),
153 MSPointerToMemberRepresentationMethod(
154 LangOpts.getMSPointerToMemberRepresentationMethod()),
155 VtorDispStack(LangOpts.getVtorDispMode()), PackStack(0),
156 DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
157 CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
158 PragmaAttributeCurrentTargetDecl(nullptr),
169 FullyCheckedComparisonCategories(
176 CurScope(
nullptr), Ident_super(
nullptr), Ident___float128(
nullptr) {
180 LoadedExternalKnownNamespaces =
false;
198 InitDataSharingAttributesStack();
200 std::unique_ptr<sema::SemaPPCallbacks> Callbacks =
201 std::make_unique<sema::SemaPPCallbacks>();
202 SemaPPCallbackHandler = Callbacks.get();
204 SemaPPCallbackHandler->set(*
this);
208 void Sema::anchor() {}
218 SC->InitializeSema(*
this);
223 ExternalSema->InitializeSema(*
this);
332 std::vector<QualType> Atomic64BitTypes;
333 Atomic64BitTypes.push_back(AtomicLongT);
334 Atomic64BitTypes.push_back(AtomicULongT);
335 Atomic64BitTypes.push_back(AtomicDoubleT);
337 Atomic64BitTypes.push_back(AtomicSizeT);
338 Atomic64BitTypes.push_back(AtomicIntPtrT);
339 Atomic64BitTypes.push_back(AtomicUIntPtrT);
340 Atomic64BitTypes.push_back(AtomicPtrDiffT);
342 for (
auto &I : Atomic64BitTypes)
344 "cl_khr_int64_base_atomics cl_khr_int64_extended_atomics");
351 #define GENERIC_IMAGE_TYPE_EXT(Type, Id, Ext) \ 352 setOpenCLExtensionForType(Context.Id, Ext); 353 #include "clang/Basic/OpenCLImageTypes.def" 354 #define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \ 355 addImplicitTypedef(#ExtType, Context.Id##Ty); \ 356 setOpenCLExtensionForType(Context.Id##Ty, #Ext); 357 #include "clang/Basic/OpenCLExtensionTypes.def" 361 #define SVE_TYPE(Name, Id, SingletonId) \ 362 addImplicitTypedef(Name, Context.SingletonId); 363 #include "clang/Basic/AArch64SVEACLETypes.def" 391 ExternalSema->ForgetSema();
394 if (isMultiplexExternalSource)
395 delete ExternalSource;
398 std::vector<ConstraintSatisfaction *> Satisfactions;
399 Satisfactions.reserve(Satisfactions.size());
400 for (
auto &
Node : SatisfactionCache)
401 Satisfactions.push_back(&
Node);
402 for (
auto *
Node : Satisfactions)
408 DestroyDataSharingAttributesStack();
412 SemaPPCallbackHandler->
reset();
418 Diag(Loc, diag::warn_stack_exhausted);
424 llvm::function_ref<
void()> Fn) {
433 UnavailableAttr::ImplicitReason reason) {
436 if (!fn)
return false;
447 if (fn->
hasAttr<UnavailableAttr>())
return true;
449 fn->
addAttr(UnavailableAttr::CreateImplicit(
Context,
"", reason, loc));
463 assert(E &&
"Cannot use with NULL ptr");
465 if (!ExternalSource) {
470 if (isMultiplexExternalSource)
474 isMultiplexExternalSource =
true;
480 llvm::errs() <<
"\n*** Semantic Analysis Stats:\n";
498 Diag(Loc, diag::warn_nullability_lost) << SrcType << DstType;
509 if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
537 llvm_unreachable(
"can't implicitly cast lvalue to rvalue with this cast " 540 case CK_LValueToRValue:
541 case CK_ArrayToPointerDecay:
542 case CK_FunctionToPointerDecay:
544 case CK_NonAtomicToAtomic:
549 "can't cast rvalue to lvalue");
558 if (ExprTy == TypeTy)
570 E = Materialized.
get();
574 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
575 ImpCast->setType(Ty);
576 ImpCast->setValueKind(VK);
599 llvm_unreachable(
"unknown scalar type kind");
610 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
614 for (
const auto *Spec : Template->specializations())
621 if (FD->hasBody(DeclToCheck))
627 if (DeclToCheck != FD)
631 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
637 if (VD->isReferenced() &&
638 VD->mightBeUsableInConstantExpressions(SemaRef->
Context))
644 for (
const auto *Spec : Template->specializations())
657 if (DeclToCheck != VD)
665 if (
auto *FD = dyn_cast<FunctionDecl>(ND))
666 return FD->isExternC();
692 if (ND->
hasAttr<WeakRefAttr>())
continue;
694 if (isa<CXXDeductionGuideDecl>(ND))
697 if (ND->
hasAttr<DLLImportAttr>() || ND->
hasAttr<DLLExportAttr>()) {
707 if (FD->isExternallyVisible() &&
709 !FD->getMostRecentDecl()->isInlined() &&
710 !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
712 if (FD->getBuiltinID())
715 auto *VD = cast<VarDecl>(ND);
718 if (VD->isExternallyVisible() &&
720 !VD->getMostRecentDecl()->isInline() &&
721 !VD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
726 if (VD->isKnownToBeDefined())
730 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));
742 if (Undefined.empty())
return;
744 for (
auto Undef : Undefined) {
745 ValueDecl *VD = cast<ValueDecl>(Undef.first);
759 ? diag::ext_undefined_internal_type
760 : diag::err_undefined_internal_type)
761 << isa<VarDecl>(VD) << VD;
767 << isa<VarDecl>(VD) << VD;
768 }
else if (
auto *FD = dyn_cast<FunctionDecl>(VD)) {
770 assert(FD->getMostRecentDecl()->isInlined() &&
771 "used object requires definition but isn't inline or internal?");
775 assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() &&
776 "used var requires definition but isn't inline or internal?");
779 if (UseLoc.isValid())
780 S.
Diag(UseLoc, diag::note_used_here);
792 for (
auto &WeakID : WeakIDs)
805 RecordCompleteMap &MNCComplete) {
806 RecordCompleteMap::iterator
Cache = MNCComplete.find(RD);
807 if (Cache != MNCComplete.end())
808 return Cache->second;
811 bool Complete =
true;
814 I != E && Complete; ++I) {
816 Complete = M->isDefined() || M->isDefaulted() ||
817 (M->isPure() && !isa<CXXDestructorDecl>(M));
823 Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
824 F->getTemplatedDecl()->isDefined();
825 else if (
const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
826 if (R->isInjectedClassName())
828 if (R->hasDefinition())
835 MNCComplete[RD] = Complete;
847 RecordCompleteMap &RecordsComplete,
848 RecordCompleteMap &MNCComplete) {
849 RecordCompleteMap::iterator
Cache = RecordsComplete.find(RD);
850 if (Cache != RecordsComplete.end())
851 return Cache->second;
855 I != E && Complete; ++I) {
859 if (
CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
866 dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
867 Complete = FD->isDefined();
873 RecordsComplete[RD] = Complete;
882 if (TD->isReferenced())
884 Diag(TD->getLocation(), diag::warn_unused_local_typedef)
885 << isa<TypeAliasDecl>(TD) << TD->getDeclName();
887 UnusedLocalTypedefNameCandidates.clear();
901 ModuleScopes.back().ImplicitGlobalModuleFragment =
true;
907 if (Kind == TUFragmentKind::Global)
938 if (ExternalSource) {
942 for (
auto PII : Pending)
943 if (
auto Func = dyn_cast<FunctionDecl>(PII.first))
944 Func->setInstantiationIsPending(
true);
946 Pending.begin(), Pending.end());
950 llvm::TimeTraceScope TimeScope(
"PerformPendingInstantiations");
956 finalizeOpenMPDelayedAnalysis();
959 "end of TU template instantiation should not create more " 960 "late-parsed templates");
965 for (
const auto &Typo : DelayedTypos) {
969 DelayedTypos.clear();
977 &&
"reached end of translation unit with a pool attached?");
990 !ModuleScopes.empty() && ModuleScopes.back().Module->Kind ==
992 ? TUFragmentKind::Private
1042 if (WeakID.second.getUsed())
1047 if (PrevDecl !=
nullptr &&
1048 !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
1049 Diag(WeakID.second.getLocation(), diag::warn_attribute_wrong_decl_type)
1052 Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
1067 bool DiagnosedMissingModuleDeclaration =
false;
1068 if (!ModuleScopes.empty() &&
1070 !ModuleScopes.back().ImplicitGlobalModuleFragment) {
1071 Diag(ModuleScopes.back().BeginLoc,
1072 diag::err_module_declaration_missing_after_global_module_introducer);
1073 DiagnosedMissingModuleDeclaration =
true;
1081 (ModuleScopes.empty() ||
1082 !ModuleScopes.back().Module->isModulePurview()) &&
1083 !DiagnosedMissingModuleDeclaration) {
1087 diag::err_module_declaration_missing);
1096 Stack.push_back(CurrentModule);
1097 while (!Stack.empty()) {
1098 Module *Mod = Stack.pop_back_val();
1129 llvm::SmallSet<VarDecl *, 32> Seen;
1130 for (TentativeDefinitionsType::iterator
1151 diag::err_tentative_def_incomplete_type))
1163 if (!D || D->isInvalidDecl() || D->getPreviousDecl() || !D->isUsed())
1175 for (UnusedFileScopedDeclsType::iterator
1181 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
1183 if (!FD->hasBody(DiagD))
1188 if (isa<CXXMethodDecl>(DiagD))
1192 if (FD->getStorageClass() ==
SC_Static &&
1193 !FD->isInlineSpecified() &&
1197 diag::warn_unneeded_static_internal_decl)
1204 if (FD->getDescribedFunctionTemplate())
1209 isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
1210 : diag::warn_unused_function)
1216 DiagD = cast<VarDecl>(*I);
1243 RecordCompleteMap RecordsComplete;
1244 RecordCompleteMap MNCComplete;
1260 for (
const auto &DeletedFieldInfo :
DeleteExprs) {
1262 AnalyzeDeleteExprMismatch(DeletedFieldInfo.first,
DeleteExprLoc.first,
1272 "Didn't unmark var as having its initializer parsed");
1287 if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC) ||
1288 isa<RequiresExprBodyDecl>(DC)) {
1290 }
else if (isa<CXXMethodDecl>(DC) &&
1291 cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
1292 cast<CXXRecordDecl>(DC->
getParent())->isLambda()) {
1311 while (isa<RecordDecl>(DC))
1318 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
1319 return cast<NamedDecl>(DC);
1351 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1353 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
1376 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1378 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
1387 Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1400 (*Info)->addSuppressedDiagnostic(DiagInfo.
getLocation(),
1441 S.
Diags.
Report(FnIt->second.Loc, diag::note_called_by));
1442 Builder << FnIt->second.FD;
1443 Builder.setForceEmit();
1455 bool HasWarningOrError =
false;
1470 if (HasWarningOrError && ShowCallStack)
1501 : S(S), Loc(Loc), DiagID(DiagID), Fn(Fn),
1502 ShowCallStack(K == K_ImmediateWithCallStack || K == K_Deferred) {
1508 ImmediateDiag.emplace(S.
Diag(Loc, DiagID));
1511 assert(Fn &&
"Must have a function to attach the deferred diag to.");
1513 PartialDiagId.emplace(
Diags.size());
1520 : S(D.S), Loc(D.Loc), DiagID(D.DiagID), Fn(D.Fn),
1521 ShowCallStack(D.ShowCallStack), ImmediateDiag(D.ImmediateDiag),
1522 PartialDiagId(D.PartialDiagId) {
1524 D.ShowCallStack =
false;
1525 D.ImmediateDiag.reset();
1526 D.PartialDiagId.reset();
1530 if (ImmediateDiag) {
1535 ImmediateDiag.reset();
1536 if (IsWarningOrError && ShowCallStack)
1539 assert((!PartialDiagId || ShowCallStack) &&
1540 "Must always show call stack for deferred diags.");
1552 if (IsKnownEmitted(S, OrigCallee)) {
1566 llvm::SmallSet<CanonicalDeclPtr<FunctionDecl>, 4> Seen;
1567 Seen.insert(OrigCallee);
1568 while (!Worklist.empty()) {
1569 CallInfo
C = Worklist.pop_back_val();
1570 assert(!IsKnownEmitted(S, C.Callee) &&
1571 "Worklist should not contain known-emitted functions.");
1578 if (
auto *Templ = C.Callee->getPrimaryTemplate()) {
1581 Seen.insert(TemplFD);
1583 { C.Caller, TemplFD, C.Loc});
1596 if (Seen.count(NewCallee) || IsKnownEmitted(S, NewCallee))
1598 Seen.insert(NewCallee);
1600 { C.Callee, NewCallee, CallLoc});
1680 pushOpenMPFunctionRegion();
1685 BlockScope, Block));
1696 LSI->AutoTemplateParameterDepth =
Depth;
1700 "Remove assertion if intentionally called in a non-lambda context.");
1735 VarDecl *VD = BC.getVariable();
1736 if (VD->
hasAttr<BlocksAttr>()) {
1745 QualType CapType = BC.getVariable()->getType();
1786 popOpenMPFunctionRegion(
Scope.get());
1792 for (
const auto &PUD :
Scope->PossiblyUnreachableDiags)
1793 Diag(PUD.Loc, PUD.PD);
1802 Self->CachedFunctionScope.reset(Scope);
1813 assert(!CurFunction->
CompoundScopes.empty() &&
"mismatched push/pop");
1844 if (CurBSI && CurBSI->TheDecl &&
1868 if (
auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope)) {
1869 if (LSI->Lambda && !LSI->Lambda->Encloses(
CurContext)) {
1887 if (IgnoreNonLambdaCapturingScope) {
1889 while (I != E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I))
1895 if (CurLSI && CurLSI->Lambda &&
1909 return (LSI->TemplateParams.size() ||
1910 LSI->GLTemplateParameterList) ? LSI :
nullptr;
1917 if (!
LangOpts.RetainCommentsFromSystemHeaders &&
1924 StringRef MagicMarkerText;
1927 MagicMarkerText =
"///<";
1930 MagicMarkerText =
"/**<";
1933 llvm_unreachable(
"if this is an almost Doxygen comment, " 1934 "it should be ordinary");
1936 Diag(Comment.
getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
1944 char ExternalSemaSource::ID;
1954 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
1973 OverloadSet.
clear();
1976 bool IsMemExpr =
false;
1990 bool Ambiguous =
false;
1995 DeclsEnd = Overloads->
decls_end(); it != DeclsEnd; ++it) {
2003 = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
2004 if (OverloadDecl->getMinRequiredArguments() == 0) {
2005 if (!ZeroArgCallReturnTy.
isNull() && !Ambiguous &&
2006 (!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() ||
2007 OverloadDecl->isCPUSpecificMultiVersion()))) {
2011 ZeroArgCallReturnTy = OverloadDecl->getReturnType();
2012 IsMV = OverloadDecl->isCPUDispatchMultiVersion() ||
2013 OverloadDecl->isCPUSpecificMultiVersion();
2021 return !ZeroArgCallReturnTy.
isNull();
2032 ZeroArgCallReturnTy = R.
get()->getType();
2039 if (
const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
2040 if (Fun->getMinRequiredArguments() == 0)
2041 ZeroArgCallReturnTy = Fun->getReturnType();
2057 dyn_cast_or_null<FunctionProtoType>(FunTy)) {
2058 if (FPT->getNumParams() == 0)
2079 int ShownOverloads = 0;
2080 int SuppressedOverloads = 0;
2082 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
2086 ++SuppressedOverloads;
2093 if (FD->isMultiVersion() && FD->hasAttr<TargetAttr>() &&
2094 !FD->getAttr<TargetAttr>()->isDefaultVersion())
2101 if (SuppressedOverloads)
2102 S.
Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
2103 << SuppressedOverloads;
2108 bool (*IsPlausibleResult)(
QualType)) {
2109 if (!IsPlausibleResult)
2114 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
2115 const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
2117 if (IsPlausibleResult(OverloadResultTy))
2118 PlausibleOverloads.
addDecl(It.getDecl());
2129 return (!isa<CStyleCastExpr>(E) &&
2130 !isa<UnaryOperator>(E) &&
2131 !isa<BinaryOperator>(E) &&
2132 !isa<CXXOperatorCallExpr>(E));
2136 if (
const auto *UO = dyn_cast<UnaryOperator>(E))
2137 E = UO->getSubExpr();
2139 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(E)) {
2140 if (ULE->getNumDecls() == 0)
2143 const NamedDecl *ND = *ULE->decls_begin();
2144 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
2145 return FD->isCPUDispatchMultiVersion() || FD->isCPUSpecificMultiVersion();
2152 bool (*IsPlausibleResult)(
QualType)) {
2159 !ZeroArgCallTy.
isNull() &&
2160 (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
2167 Diag(Loc, PD) << 1 << IsMV << Range
2181 if (!ForceComplain)
return false;
2184 Diag(Loc, PD) << 0 << IsMV << Range;
2198 if (!Ident___float128)
2200 return Ident___float128;
2205 unsigned OpenMPCaptureLevel) {
2209 OpenMPCaptureLevel);
2221 const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
2230 ExtStr.split(Exts,
" ", -1,
false);
2232 for (
auto &I : Exts)
2233 OpenCLTypeExtMap[CanT].insert(I.str());
2238 ExtStr.split(Exts,
" ", -1,
false);
2241 for (
auto &I : Exts)
2242 OpenCLDeclExtMap[FD].insert(I.str());
2246 if (CurrOpenCLExtension.empty())
2252 if (CurrOpenCLExtension.empty())
2258 if (!OpenCLDeclExtMap.empty())
2265 if (!OpenCLTypeExtMap.empty())
2271 template <
typename T,
typename MapT>
2273 std::string ExtensionNames =
"";
2274 auto Loc = Map.find(FDT);
2276 for (
auto const& I : Loc->second) {
2277 ExtensionNames += I;
2278 ExtensionNames +=
" ";
2280 ExtensionNames.pop_back();
2282 return ExtensionNames;
2286 auto Loc = OpenCLDeclExtMap.find(FD);
2287 if (Loc == OpenCLDeclExtMap.end())
2289 for (
auto &I : Loc->second) {
2296 template <
typename T,
typename DiagLocT,
typename DiagInfoT,
typename MapT>
2297 bool Sema::checkOpenCLDisabledTypeOrDecl(T D, DiagLocT DiagLoc,
2298 DiagInfoT DiagInfo, MapT &Map,
2301 auto Loc = Map.find(D);
2302 if (Loc == Map.end())
2304 bool Disabled =
false;
2305 for (
auto &I : Loc->second) {
2307 Diag(DiagLoc, diag::err_opencl_requires_extension) << Selector << DiagInfo
2318 if (
auto TypedefT = dyn_cast<TypedefType>(QT.
getTypePtr()))
2319 Decl = TypedefT->getDecl();
2321 Decl = TagT->getDecl();
2328 return checkOpenCLDisabledTypeOrDecl(TypePtr, Loc, QT, OpenCLTypeExtMap);
2331 if (checkOpenCLDisabledTypeOrDecl(Decl, Loc, QT, OpenCLDeclExtMap))
2336 QT, OpenCLTypeExtMap);
2341 return checkOpenCLDisabledTypeOrDecl(&D, E.
getBeginLoc(), FnName,
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=TTK_Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
SourceLocation getLocForStartOfFile(FileID FID) const
Return the source location corresponding to the first byte of the specified file. ...
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
Defines the clang::ASTContext interface.
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used...
Represents a function declaration or definition.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
bool hasErrorOccurred() const
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
Smart pointer class that efficiently represents Objective-C method names.
A class which contains all the information about a particular captured value.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
TypedefDecl * getCFConstantStringDecl() const
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
bool hasNonTrivialToPrimitiveCopyCUnion() const
Check if this is or contains a C union that is non-trivial to copy, which is a union that has a membe...
LateTemplateParserCB * LateTemplateParser
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
DeviceDiagBuilder(Kind K, SourceLocation Loc, unsigned DiagID, FunctionDecl *Fn, Sema &S)
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs...
DeclContext * getFunctionLevelDeclContext()
RecordDecl * MSVCGuidDecl
The MSVC "_GUID" struct, which is defined in MSVC header files.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
Emit the diagnostic immediately, and, if it's a warning or error, also emit a call stack showing how ...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
void CheckCompleteVariableDeclaration(VarDecl *VD)
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
submodule_iterator submodule_begin()
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
FunctionType - C99 6.7.5.3 - Function Declarators.
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedOverridingExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
virtual void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
Callback invoked whenever a source file is entered or exited.
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Decl - This represents one declaration (or definition), e.g.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
static void emitDeferredDiags(Sema &S, FunctionDecl *FD, bool ShowCallStack)
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
bool isExtVectorType() const
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
The translation unit is a prefix to a translation unit, and is not complete.
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
virtual void updateOutOfDateSelector(Selector Sel)
Load the contents of the global method pool for a given selector if necessary.
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
const DiagnosticBuilder & setForceEmit() const
Forces the diagnostic to be emitted.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Declaration of a variable template.
static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
const TargetInfo & getTargetInfo() const
void checkNonTrivialCUnion(QualType QT, SourceLocation Loc, NonTrivialCUnionContext UseContext, unsigned NonTrivialKind)
Emit diagnostics if a non-trivial C union type or a struct that contains a non-trivial C union is use...
A container of type source information.
Linkage getLinkage() const
Determine the linkage of this type.
bool getSuppressSystemWarnings() const
IdentifierInfo * getSuperIdentifier() const
The diagnostic should not be reported, but it should cause template argument deduction to fail...
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
unsigned NonInstantiationEntries
The number of CodeSynthesisContexts that are not template instantiations and, therefore, should not be counted as part of the instantiation depth.
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
IdentifierInfo * getFloat128Identifier() const
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
Retains information about a function, method, or block that is currently being parsed.
std::string getOpenCLExtensionsFromTypeExtMap(FunctionType *FT)
Check if a function type FT associates with any extensions present in OpenCLTypeExtMap and if so retu...
RAII object that enters a new expression evaluation context.
Compiling a C++ modules TS module interface unit.
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
QualType getReturnType() const
DiagnosticsEngine & Diags
virtual void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI)
Read the set of weak, undeclared identifiers known to the external Sema source.
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
void enableSupportedCore(LangOptions LO)
LangAS
Defines the address space values used by the address space qualifier of QualType. ...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
unsigned getDiagID() const
bool isInvalidDecl() const
Describes how types, statements, expressions, and declarations should be printed. ...
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
This interface provides a way to observe the actions of the preprocessor as it does its thing...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit...
iterator begin(Source *source, bool LocalOnly=false)
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
void threadSafetyCleanup(BeforeSet *Cache)
void CheckDelayedMemberExceptionSpecs()
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
Represents a struct/union/class.
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
An iterator over the friend declarations of a class.
This is the private module fragment within some C++ module.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
virtual void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls)
Read the set of potentially unused typedefs known to the source.
bool doesNotEscape() const
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
sema::FunctionScopeInfo * getEnclosingFunction() const
bool resolveConflicts(Module *Mod, bool Complain)
Resolve all of the unresolved conflicts in the given module.
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
unsigned getCurrentDiagID() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceLocation getTypeSpecTypeLoc() const
DeviceDiagBuilder diagIfOpenMPHostCode(SourceLocation Loc, unsigned DiagID)
Creates a DeviceDiagBuilder that emits the diagnostic if the current context is "used as host code"...
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
SourceLocation getBeginLoc() const LLVM_READONLY
void setCurrentOpenCLExtensionForType(QualType T)
Set current OpenCL extensions for a type which can only be used when these OpenCL extensions are enab...
Represents a member of a struct/union/class.
void erase(iterator From, iterator To)
The current expression is potentially evaluated at run time, which means that code may be generated t...
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
std::unique_ptr< sema::FunctionScopeInfo > CachedFunctionScope
threadSafety::BeforeSet * ThreadSafetyDeclCache
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
The iterator over UnresolvedSets.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
bool hasAArch64SVETypes() const
Returns whether or not the AArch64 SVE built-in types are available on this target.
llvm::SmallPtrSet< const BlockDecl *, 1 > Blocks
The set of blocks that are introduced in this function.
void setFunctionHasBranchIntoScope()
Represents a C++ member access expression for which lookup produced a set of overloaded functions...
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
bool isOpenCLDisabledDecl(Decl *FD)
CanQualType OCLReserveIDTy
const LangOptions & getLangOpts() const
Describes a module or submodule.
llvm::BumpPtrAllocator BumpAlloc
static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc)
Give notes for a set of overloads.
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Values of this type can be null.
iterator end()
end - Returns an iterator that has 'finished'.
DiagnosticErrorTrap ErrorTrap
Used to determine if errors occurred in this function or block.
An abstract interface that should be implemented by clients that read ASTs and then require further s...
DeviceDiagBuilder CUDADiagIfDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a DeviceDiagBuilder that emits the diagnostic if the current context is "used as device code"...
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
static bool MethodsAndNestedClassesComplete(const CXXRecordDecl *RD, RecordCompleteMap &MNCComplete)
Returns true, if all methods and nested classes of the given CXXRecordDecl are defined in this transl...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
DeviceDiagBuilder targetDiag(SourceLocation Loc, unsigned DiagID)
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isReferenced() const
Whether any declaration of this entity was referenced.
HeaderSearch & getHeaderSearchInfo() const
bool HasFormOfMemberPointer
const SourceLocation & getLocation() const
bool checkOpenCLDisabledTypeDeclSpec(const DeclSpec &DS, QualType T)
Check if type T corresponding to declaration specifier DS is disabled due to required OpenCL extensio...
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
CanThrowResult canThrow(const Stmt *E)
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
const clang::PrintingPolicy & getPrintingPolicy() const
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
bool hasNonTrivialToPrimitiveDestructCUnion() const
Check if this is or contains a C union that is non-trivial to destruct, which is a union that has a m...
A set of unresolved declarations.
SmallVector< VarDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
void CheckDelegatingCtorCycles()
CheckedConversionKind
The kind of conversion being performed.
friend_iterator friend_end() const
~ExternalSemaSource() override
Values of this type can never be null.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
Scope - A scope is a transient data structure that is used while parsing the program.
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
static const unsigned NumNSNumberLiteralMethods
submodule_iterator submodule_end()
void PrintStats() const
Print out statistics about the semantic analysis.
void emitAndClearUnusedLocalTypedefWarnings()
SourceLocation getCurrentDiagLoc() const
virtual ASTMutationListener * GetASTMutationListener()
If the consumer is interested in entities getting modified after their initial creation, it should return a pointer to an ASTMutationListener here.
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
virtual void ReadKnownNamespaces(SmallVectorImpl< NamespaceDecl *> &Namespaces)
Load the set of namespaces that are known to the external source, which will be used during typo corr...
const LangOptions & getLangOpts() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
Represents the body of a CapturedStmt, and serves as its DeclContext.
NamespaceDecl * StdExperimentalNamespaceCache
The C++ "std::experimental" namespace, where the experimental parts of the standard library resides...
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
void DiagnoseNonDefaultPragmaPack(PragmaPackDiagnoseKind Kind, SourceLocation IncludeLoc)
const LangOptions & LangOpts
bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E)
Check if declaration D used by expression E is disabled due to required OpenCL extensions being disab...
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
Contains information about the compound statement currently being parsed.
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
DiagnosticsEngine & getDiagnostics() const
static bool IsCallableWithAppend(Expr *E)
Determine whether the given expression can be called by just putting parentheses after it...
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
bool isExternalFormalLinkage(Linkage L)
Sema - This implements semantic analysis and AST building for C.
A little helper class used to produce diagnostics.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
Represents a prototype with parameter type info, e.g.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Retains information about a captured region.
void PushCompoundScope(bool IsStmtExpr)
Represents a ValueDecl that came out of a declarator.
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type...
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &)
void setFunctionHasBranchProtectedScope()
bool isEnabled(llvm::StringRef Ext) const
Scope * getCurScope() const
Retrieve the parser's current scope.
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
CommentOptions CommentOpts
Options for parsing comments.
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
Retains information about a block that is currently being parsed.
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
An abstract interface that should be implemented by external AST sources that also provide informatio...
Represents a block literal declaration, which is like an unnamed FunctionDecl.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D)
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
This represents one expression.
void setOpenCLExtensionForDecl(Decl *FD, llvm::StringRef Exts)
Set OpenCL extensions for a declaration which can only be used when these OpenCL extensions are enabl...
Show just the "best" overload candidates.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
void addImplicitTypedef(StringRef Name, QualType T)
ExprResult BuildCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
BuildCallExpr - Handle a call to Fn with the specified array of arguments.
const T * castAs() const
Member-template castAs<specific type>.
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool InNonInstantiationSFINAEContext
Whether we are in a SFINAE context that is not associated with template instantiation.
Defines the clang::Preprocessor interface.
bool isNullPtrType() const
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Not compiling a module interface at all.
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
DeclContext * getDeclContext()
bool resolveExports(Module *Mod, bool Complain)
Resolve all of the unresolved exports in the given module.
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
decls_iterator decls_begin() const
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
bool WarnedStackExhausted
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
void Clear()
Clear out the current diagnostic.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
PartialDiagnostic::StorageAllocator & getDiagAllocator()
virtual void CompleteExternalDeclaration(VarDecl *D)
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isExternallyVisible(Linkage L)
SourceLocation getEnd() const
Preprocessor & getPreprocessor() const
SourceLocation getCaretLocation() const
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
void DiagnoseUnterminatedPragmaPack()
bool isNull() const
Return true if this QualType doesn't point to a type yet.
OverloadsShown getShowOverloads() const
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
llvm::DenseMap< const CXXRecordDecl *, bool > RecordCompleteMap
An abstract interface that should be implemented by external AST sources that also provide informatio...
bool isConstQualified() const
Determine whether this type is const-qualified.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool'...
bool isStructureOrClassType() const
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
void Emit(const DiagnosticBuilder &DB) const
RecordDecl * CXXTypeInfoDecl
The C++ "type_info" declaration, which is defined in <typeinfo>.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
QualType getCanonicalType() const
ActionResult - This structure is used while parsing/acting on expressions, stmts, etc...
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
Encodes a location in the source.
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
QualType getReturnType() const
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
void setCurrentOpenCLExtensionForDecl(Decl *FD)
Set current OpenCL extensions for a declaration which can only be used when these OpenCL extensions a...
Diagnostic builder for CUDA/OpenMP devices errors which may or may not be deferred.
StringRef getName() const
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
decl_iterator decls_begin() const
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
Cached information about one file (either on disk or in the virtual file system). ...
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
std::string getOpenCLExtensionsFromDeclExtMap(FunctionDecl *FD)
Check if a function declaration FD associates with any extensions present in OpenCLDeclExtMap and if ...
bool isExternalWithNoLinkageType(ValueDecl *VD)
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
ClassTemplateDecl * StdInitializerList
The C++ "std::initializer_list" template, which is defined in <initializer_list>. ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
Represents a static or instance method of a struct/union/class.
void DiagnoseUseOfUnimplementedSelectors()
DeclGroupPtrTy ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc)
The parser has processed a global-module-fragment declaration that begins the definition of the globa...
This is a fragment of the global module within some C++ module.
static void emitCallStackNotes(Sema &S, FunctionDecl *FD)
void markKnownEmitted(Sema &S, FunctionDecl *OrigCaller, FunctionDecl *OrigCallee, SourceLocation OrigLoc, const llvm::function_ref< bool(Sema &, FunctionDecl *)> IsKnownEmitted)
Indicate that this function (and thus everything it transtively calls) will be codegen'ed, and emit any deferred diagnostics on this function and its (transitive) callees.
void addDecl(NamedDecl *D)
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
virtual void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
This declaration is only a declaration.
void addSupport(const OpenCLOptions &Opts)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
The diagnostic should be suppressed entirely.
static bool IsRecordFullyDefined(const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete)
Returns true, if the given CXXRecordDecl is fully defined in this translation unit, i.e.
friend_iterator friend_begin() const
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
Create a deferred diagnostic, which is emitted only if the function it's attached to is codegen'ed...
static bool isFunctionOrVarDeclExternC(NamedDecl *ND)
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
void operator()(sema::FunctionScopeInfo *Scope) const
static bool isBuiltinNote(unsigned DiagID)
Determine whether the given built-in diagnostic ID is a Note.
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed...
ASTConsumer & getASTConsumer() const
void setOpenCLExtensionForType(QualType T, llvm::StringRef Exts)
Set OpenCL extensions for a type which can only be used when these OpenCL extensions are enabled...
StringRef getName() const
Return the actual identifier string.
decl_iterator - Iterates through the declarations stored within this context.
Base class for declarations which introduce a typedef-name.
ast_type_traits::DynTypedNode Node
Abstract interface for a consumer of code-completion information.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
LateTemplateParserCleanupCB * LateTemplateParserCleanup
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
bool isValid() const
Return true if this is a valid SourceLocation object.
int ArgumentPackSubstitutionIndex
The current index into pack expansion arguments that will be used for substitution of parameter packs...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
static void checkEscapingByref(VarDecl *VD, Sema &S)
ArrayRef< Capture > captures() const
ASTMutationListener * getASTMutationListener() const
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
SourceLocation getIncludeLoc(FileID FID) const
Returns the include location if FID is a #include'd file otherwise it returns an invalid location...
This is a scope that corresponds to the template parameters of a C++ template.
ClassTemplateDecl * StdCoroutineTraitsCache
The C++ "std::coroutine_traits" template, which is defined in <coroutine_traits>
FileID getMainFileID() const
Returns the FileID of the main source file.
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared...
The name of a declaration.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
OverloadExpr * Expression
A set of unresolved declarations.
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created...
Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
IdentifierResolver IdResolver
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
DeviceDiagBuilder diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID)
Creates a DeviceDiagBuilder that emits the diagnostic if the current context is "used as device code"...
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
Abstract interface for a module loader.
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
std::string getOpenCLExtensionsFromExtMap(T *FT, MapT &Map)
Find an extension in an appropriate extension map and return its name.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
void DiagnoseUnterminatedPragmaAttribute()
Encapsulates the data about a macro definition (e.g.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point...
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
void FormatASTNodeDiagnosticArgument(DiagnosticsEngine::ArgumentKind Kind, intptr_t Val, StringRef Modifier, StringRef Argument, ArrayRef< DiagnosticsEngine::ArgumentValue > PrevArgs, SmallVectorImpl< char > &Output, void *Cookie, ArrayRef< intptr_t > QualTypeVals)
DiagnosticsEngine argument formatting function for diagnostics that involve AST nodes.
CanQualType UnsignedLongTy
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S)
ExtVectorType - Extended vector type.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void addComment(const RawComment &RC)
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
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.
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This is a scope that can contain a declaration.
SourceManager & getSourceManager()
void ActOnTranslationUnitScope(Scope *S)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool isConstantEvaluatedOverride
Used to change context to isConstantEvaluated without pushing a heavy ExpressionEvaluationContextReco...
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, std::vector< PartialDiagnosticAt > > DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const VarDecl *NRVOCandidate, QualType ResultType, Expr *Value, bool AllowNRVO=true)
Perform the initialization of a potentially-movable value, which is the result of return value...
TranslationUnitDecl * getTranslationUnitDecl() const
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
Captures information about "declaration specifiers".
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID)
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs d...
Represents a C++ struct/union/class.
void setFunctionHasIndirectGoto()
Represents a C array with an unspecified size.
sema::FunctionScopeInfo * getCurFunction() const
PoppedFunctionScopePtr PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, QualType BlockType=QualType())
Pop a function (or block or lambda or captured region) scope from the stack.
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
TranslationUnitKind
Describes the kind of translation unit being processed.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
SourceManager & getSourceManager() const
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Defines the clang::TargetInfo interface.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
The diagnostic should be reported.
void ActOnComment(SourceRange Comment)
virtual void ReadPendingInstantiations(SmallVectorImpl< std::pair< ValueDecl *, SourceLocation > > &Pending)
Read the set of pending instantiations known to the external Sema source.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts ...
A reference to a declared variable, function, enum, etc.
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Defines utilities for dealing with stack allocation and stack space.
NamedDecl * getMostRecentDecl()
bool isDeleted() const
Whether this function has been deleted.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
SourceManager & SourceMgr
CapturedRegionKind
The different kinds of captured statement.
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, FunctionDeclAndLoc > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
An l-value expression is a reference to an object with independent storage.
virtual void CompleteTentativeDefinition(VarDecl *D)
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
A wrapper class around a pointer that always points to its canonical declaration. ...
A trivial tuple used to represent a source range.
llvm::TinyPtrVector< VarDecl * > ByrefBlockVars
The set of __block variables that are introduced in this function.
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one. ...
This represents a decl that may have a name.
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
IdentifierInfo * getBoolName() const
Retrieve the identifier 'bool'.
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType)
void setType(QualType newType)
SourceLocation getBegin() const
const LangOptions & getLangOpts() const
bool isPlainFunction() const
static void checkUndefinedButUsed(Sema &S)
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline...
decls_iterator decls_end() const
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
This class handles loading and caching of source files into memory.
OpenCLOptions & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
Declaration of a template function.
void PushFunctionScope()
Enter a new function scope.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
SourceLocation getLocation() const
llvm::DenseMap< CanonicalDeclPtr< FunctionDecl >, llvm::MapVector< CanonicalDeclPtr< FunctionDecl >, SourceLocation > > DeviceCallGraph
A partial call graph maintained during CUDA/OpenMP device code compilation to support deferred diagno...
DeviceDiagBuilder CUDADiagIfHostCode(SourceLocation Loc, unsigned DiagID)
Creates a DeviceDiagBuilder that emits the diagnostic if the current context is "used as host code"...
bool isExternallyVisible() const
CanQualType OCLClkEventTy
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
CanQualType UnsignedIntTy
decl_iterator decls_end() const
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
static bool isExternC(const NamedDecl *ND)
The translation unit is a module.