75#include "llvm/ADT/DenseMap.h"
76#include "llvm/ADT/STLExtras.h"
77#include "llvm/ADT/SmallPtrSet.h"
78#include "llvm/Support/TimeProfiler.h"
94 if (!SDKInfo && !WarnedDarwinSDKInfoMissing) {
95 Diag(
Loc, diag::warn_missing_sdksettings_for_availability_checking)
97 WarnedDarwinSDKInfoMissing =
true;
103 if (CachedDarwinSDKInfo)
104 return CachedDarwinSDKInfo->get();
108 if (SDKInfo && *SDKInfo) {
109 CachedDarwinSDKInfo = std::make_unique<DarwinSDKInfo>(std::move(**SDKInfo));
110 return CachedDarwinSDKInfo->get();
113 llvm::consumeError(SDKInfo.takeError());
114 CachedDarwinSDKInfo = std::unique_ptr<DarwinSDKInfo>();
120 std::string InventedName;
121 llvm::raw_string_ostream
OS(InventedName);
124 OS <<
"auto:" << Index + 1;
140 Policy.
Bool = BoolMacro->isObjectLike() &&
141 BoolMacro->getNumTokens() == 1 &&
142 BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
172 FileID PrevFID)
override {
180 if (llvm::timeTraceProfilerEnabled()) {
182 ProfilerStack.push_back(llvm::timeTraceAsyncProfilerBegin(
183 "Source", FE ? FE->
getName() : StringRef(
"<unknown>")));
186 IncludeStack.push_back(IncludeLoc);
194 if (!IncludeStack.empty()) {
195 if (llvm::timeTraceProfilerEnabled())
196 llvm::timeTraceProfilerEnd(ProfilerStack.pop_back_val());
200 IncludeStack.pop_back_val());
218 CurFPFeatures(pp.getLangOpts()), LangOpts(pp.getLangOpts()), PP(pp),
219 Context(ctxt), Consumer(consumer), Diags(PP.getDiagnostics()),
220 SourceMgr(PP.getSourceManager()), APINotes(SourceMgr, LangOpts),
221 AnalysisWarnings(*this), ThreadSafetyDeclCache(nullptr),
222 LateTemplateParser(nullptr), LateTemplateParserCleanup(nullptr),
223 OpaqueParser(nullptr), CurContext(nullptr),
ExternalSource(nullptr),
224 CurScope(nullptr), Ident_super(nullptr),
251 MSPointerToMemberRepresentationMethod(
252 LangOpts.getMSPointerToMemberRepresentationMethod()),
253 MSStructPragmaOn(
false), VtorDispStack(LangOpts.getVtorDispMode()),
255 DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
256 CodeSegStack(nullptr), StrictGuardStackCheckStack(
false),
258 VisContext(nullptr), PragmaAttributeCurrentTargetDecl(nullptr),
259 StdCoroutineTraitsCache(nullptr), IdResolver(pp),
260 OriginalLexicalContext(nullptr), StdInitializerList(nullptr),
261 FullyCheckedComparisonCategories(
263 StdSourceLocationImplDecl(nullptr), CXXTypeInfoDecl(nullptr),
264 GlobalNewDeleteDeclared(
false), DisableTypoCorrection(
false),
265 TyposCorrected(0), IsBuildingRecoveryCallExpr(
false), NumSFINAEErrors(0),
266 AccessCheckingSFINAE(
false), CurrentInstantiationScope(nullptr),
267 InNonInstantiationSFINAEContext(
false), NonInstantiationEntries(0),
268 ArgumentPackSubstitutionIndex(-1), SatisfactionCache(Context) {
272 LoadedExternalKnownNamespaces =
false;
293 OpenMP().InitDataSharingAttributesStack();
295 std::unique_ptr<sema::SemaPPCallbacks> Callbacks =
296 std::make_unique<sema::SemaPPCallbacks>();
297 SemaPPCallbackHandler = Callbacks.get();
299 SemaPPCallbackHandler->
set(*
this);
322 SC->InitializeSema(*
this);
327 ExternalSema->InitializeSema(*
this);
401 if (OCLCompatibleVersion >= 200) {
430 auto AddPointerSizeDependentTypes = [&]() {
434 auto AtomicPtrDiffT =
443 AddPointerSizeDependentTypes();
451 std::vector<QualType> Atomic64BitTypes;
459 Atomic64BitTypes.push_back(AtomicDoubleT);
468 AddPointerSizeDependentTypes();
473#define EXT_OPAQUE_TYPE(ExtType, Id, Ext) \
474 if (getOpenCLOptions().isSupported(#Ext, getLangOpts())) { \
475 addImplicitTypedef(#ExtType, Context.Id##Ty); \
477#include "clang/Basic/OpenCLExtensionTypes.def"
483#define SVE_TYPE(Name, Id, SingletonId) \
484 addImplicitTypedef(Name, Context.SingletonId);
485#include "clang/Basic/AArch64SVEACLETypes.def"
489#define PPC_VECTOR_MMA_TYPE(Name, Id, Size) \
490 addImplicitTypedef(#Name, Context.Id##Ty);
491#include "clang/Basic/PPCTypes.def"
492#define PPC_VECTOR_VSX_TYPE(Name, Id, Size) \
493 addImplicitTypedef(#Name, Context.Id##Ty);
494#include "clang/Basic/PPCTypes.def"
498#define RVV_TYPE(Name, Id, SingletonId) \
499 addImplicitTypedef(Name, Context.SingletonId);
500#include "clang/Basic/RISCVVTypes.def"
505#define WASM_TYPE(Name, Id, SingletonId) \
506 addImplicitTypedef(Name, Context.SingletonId);
507#include "clang/Basic/WebAssemblyReferenceTypes.def"
513#define AMDGPU_TYPE(Name, Id, SingletonId) \
514 addImplicitTypedef(Name, Context.SingletonId);
515#include "clang/Basic/AMDGPUTypes.def"
531 "failed to clean up an InstantiatingTemplate?");
546 ExternalSema->ForgetSema();
549 std::vector<ConstraintSatisfaction *> Satisfactions;
550 Satisfactions.reserve(SatisfactionCache.size());
551 for (
auto &
Node : SatisfactionCache)
552 Satisfactions.push_back(&
Node);
553 for (
auto *
Node : Satisfactions)
559 OpenMP().DestroyDataSharingAttributesStack();
563 SemaPPCallbackHandler->
reset();
569 Diag(
Loc, diag::warn_stack_exhausted);
575 llvm::function_ref<
void()> Fn) {
580 UnavailableAttr::ImplicitReason reason) {
583 if (!fn)
return false;
594 if (fn->
hasAttr<UnavailableAttr>())
return true;
596 fn->
addAttr(UnavailableAttr::CreateImplicit(
Context,
"", reason, loc));
605 assert(
E &&
"Cannot use with NULL ptr");
612 if (
auto *Ex = dyn_cast<MultiplexExternalSemaSource>(
ExternalSource))
619 llvm::errs() <<
"\n*** Semantic Analysis Stats:\n";
629 std::optional<NullabilityKind> ExprNullability = SrcType->
getNullability();
634 std::optional<NullabilityKind> TypeNullability = DstType->
getNullability();
638 Diag(
Loc, diag::warn_nullability_lost) << SrcType << DstType;
646 if (SrcFX != DstFX) {
648 if (Diff.shouldDiagnoseConversion(SrcType, SrcFX, DstType, DstFX))
649 Diag(
Loc, diag::warn_invalid_add_func_effects) << Diff.effectName();
659 if (Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
665 if (isa<GNUNullExpr>(EStripped))
711 (
"can't implicitly cast glvalue to prvalue with this cast "
716 case CK_LValueToRValue:
717 case CK_ArrayToPointerDecay:
718 case CK_FunctionToPointerDecay:
720 case CK_NonAtomicToAtomic:
721 case CK_HLSLArrayRValue:
726 "can't cast prvalue to glvalue");
732 Kind != CK_NullToPointer && Kind != CK_NullToMemberPointer)
741 if (Kind == CK_ArrayToPointerDecay) {
750 E = Materialized.
get();
761 if (
const auto *DRE = dyn_cast<DeclRefExpr>(
E)) {
762 if (
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl())) {
774 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
775 ImpCast->setType(Ty);
776 ImpCast->setValueKind(VK);
798 llvm_unreachable(
"unknown scalar type kind");
806 if (
D->isExternallyVisible())
813 for (
const auto *Spec : Template->specializations())
820 if (FD->hasBody(DeclToCheck))
826 if (DeclToCheck != FD)
830 if (
const VarDecl *VD = dyn_cast<VarDecl>(
D)) {
836 if (VD->isReferenced() &&
837 VD->mightBeUsableInConstantExpressions(SemaRef->
Context))
843 for (
const auto *Spec : Template->specializations())
856 if (DeclToCheck != VD)
864 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
865 return FD->isExternC();
866 return cast<VarDecl>(ND)->isExternC();
891 if (ND->
hasAttr<WeakRefAttr>())
continue;
893 if (isa<CXXDeductionGuideDecl>(ND))
896 if (ND->
hasAttr<DLLImportAttr>() || ND->
hasAttr<DLLExportAttr>()) {
903 if (
const auto *FD = dyn_cast<FunctionDecl>(ND)) {
906 if (FD->isExternallyVisible() &&
908 !FD->getMostRecentDecl()->isInlined() &&
909 !FD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
911 if (FD->getBuiltinID())
914 const auto *VD = cast<VarDecl>(ND);
917 if (VD->isExternallyVisible() &&
919 !VD->getMostRecentDecl()->isInline() &&
920 !VD->hasAttr<ExcludeFromExplicitInstantiationAttr>())
925 if (VD->isKnownToBeDefined())
929 Undefined.push_back(std::make_pair(ND, UndefinedUse.second));
942 if (Undefined.empty())
return;
944 for (
const auto &Undef : Undefined) {
945 ValueDecl *VD = cast<ValueDecl>(Undef.first);
959 ? diag::ext_undefined_internal_type
960 : diag::err_undefined_internal_type)
961 << isa<VarDecl>(VD) << VD;
966 bool IsImplicitBase =
false;
967 if (
const auto *BaseD = dyn_cast<FunctionDecl>(VD)) {
968 auto *DVAttr = BaseD->
getAttr<OMPDeclareVariantAttr>();
969 if (DVAttr && !DVAttr->getTraitInfo().isExtensionActive(
970 llvm::omp::TraitProperty::
971 implementation_extension_disable_implicit_base)) {
972 const auto *
Func = cast<FunctionDecl>(
973 cast<DeclRefExpr>(DVAttr->getVariantFuncRef())->getDecl());
974 IsImplicitBase = BaseD->isImplicit() &&
975 Func->getIdentifier()->isMangledOpenMPVariantName();
980 << isa<VarDecl>(VD) << VD;
981 }
else if (
auto *FD = dyn_cast<FunctionDecl>(VD)) {
983 assert(FD->getMostRecentDecl()->isInlined() &&
984 "used object requires definition but isn't inline or internal?");
988 assert(cast<VarDecl>(VD)->getMostRecentDecl()->isInline() &&
989 "used var requires definition but isn't inline or internal?");
993 S.
Diag(UseLoc, diag::note_used_here);
1003 for (
auto &WeakID : WeakIDs)
1017 RecordCompleteMap::iterator
Cache = MNCComplete.find(RD);
1018 if (
Cache != MNCComplete.end())
1019 return Cache->second;
1027 Complete = M->isDefined() || M->isDefaulted() ||
1028 (M->isPureVirtual() && !isa<CXXDestructorDecl>(M));
1034 Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
1035 F->getTemplatedDecl()->isDefined();
1036 else if (
const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
1037 if (R->isInjectedClassName())
1039 if (R->hasDefinition())
1060 RecordCompleteMap::iterator
Cache = RecordsComplete.find(RD);
1061 if (
Cache != RecordsComplete.end())
1062 return Cache->second;
1070 if (
CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
1077 dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
1093 if (TD->isReferenced())
1095 Diag(TD->getLocation(), diag::warn_unused_local_typedef)
1096 << isa<TypeAliasDecl>(TD) << TD->getDeclName();
1104 HandleStartOfHeaderUnit();
1144 for (
auto PII : Pending)
1145 if (
auto Func = dyn_cast<FunctionDecl>(PII.first))
1146 Func->setInstantiationIsPending(
true);
1148 Pending.begin(), Pending.end());
1152 llvm::TimeTraceScope TimeScope(
"PerformPendingInstantiations");
1159 "end of TU template instantiation should not create more "
1160 "late-parsed templates");
1165 for (
const auto &Typo : DelayedTypos) {
1169 DelayedTypos.clear();
1174 &&
"reached end of translation unit with a pool attached?");
1187 !ModuleScopes.empty() && ModuleScopes.back().Module->Kind ==
1207 if (
LangOpts.PCHInstantiateTemplates) {
1208 llvm::TimeTraceScope TimeScope(
"PerformPendingInstantiations");
1231 return ShouldRemoveFromUnused(this, DD);
1245 if (WeakIDs.second.empty())
1250 if (PrevDecl !=
nullptr &&
1251 !(isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)))
1252 for (
const auto &WI : WeakIDs.second)
1253 Diag(WI.getLocation(), diag::warn_attribute_wrong_decl_type)
1256 for (
const auto &WI : WeakIDs.second)
1257 Diag(WI.getLocation(), diag::warn_weak_identifier_undeclared)
1272 if (!ModuleScopes.empty() && ModuleScopes.back().Module->Kind ==
1274 Diag(ModuleScopes.back().BeginLoc,
1275 diag::err_module_declaration_missing_after_global_module_introducer);
1287 diag::err_module_declaration_missing);
1293 auto DoesModNeedInit = [
this](
Module *M) {
1296 for (
auto [Exported, _] : M->Exports)
1297 if (Exported->isNamedModuleInterfaceHasInit())
1306 CurrentModule->NamedModuleHasInit =
1307 DoesModNeedInit(CurrentModule) ||
1308 llvm::any_of(CurrentModule->submodules(),
1309 [&](
auto *SubM) { return DoesModNeedInit(SubM); });
1319 Stack.push_back(CurrentModule);
1320 while (!Stack.empty()) {
1321 Module *Mod = Stack.pop_back_val();
1333 Stack.append(SubmodulesRange.begin(), SubmodulesRange.end());
1345 if (!PendingInlineFuncDecls.empty()) {
1346 for (
auto *
D : PendingInlineFuncDecls) {
1347 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
1348 bool DefInPMF =
false;
1349 if (
auto *FDD = FD->getDefinition()) {
1350 DefInPMF = FDD->getOwningModule()->isPrivateModule();
1354 Diag(FD->getLocation(), diag::err_export_inline_not_defined)
1359 Diag(ModuleScopes.back().BeginLoc,
1360 diag::note_private_module_fragment);
1364 PendingInlineFuncDecls.clear();
1378 llvm::SmallSet<VarDecl *, 32> Seen;
1379 for (TentativeDefinitionsType::iterator
1400 diag::err_tentative_def_incomplete_type))
1428 for (UnusedFileScopedDeclsType::iterator
1435 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
1437 if (!FD->hasBody(DiagD))
1444 DiagRange.
setEnd(ASTTAL->RAngleLoc);
1446 if (isa<CXXMethodDecl>(DiagD))
1448 << DiagD << DiagRange;
1450 if (FD->getStorageClass() ==
SC_Static &&
1451 !FD->isInlineSpecified() &&
1455 diag::warn_unneeded_static_internal_decl)
1456 << DiagD << DiagRange;
1459 << 0 << DiagD << DiagRange;
1461 }
else if (!FD->isTargetMultiVersion() ||
1462 FD->isTargetMultiVersionDefault()) {
1463 if (FD->getDescribedFunctionTemplate())
1465 << 0 << DiagD << DiagRange;
1468 ? diag::warn_unused_member_function
1469 : diag::warn_unused_function)
1470 << DiagD << DiagRange;
1475 DiagD = cast<VarDecl>(*I);
1477 if (
const auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(DiagD)) {
1479 VTSD->getTemplateArgsAsWritten())
1480 DiagRange.
setEnd(ASTTAL->RAngleLoc);
1484 << 1 << DiagD << DiagRange;
1487 << 1 << DiagD << DiagRange;
1493 << DiagD << DiagRange;
1496 << DiagD << DiagRange;
1514 <<
D->getDeclName();
1522 for (
const auto &DeletedFieldInfo :
DeleteExprs) {
1524 AnalyzeDeleteExprMismatch(DeletedFieldInfo.first,
DeleteExprLoc.first,
1536 "Didn't unmark var as having its initializer parsed");
1551 if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC) ||
1552 isa<RequiresExprBodyDecl>(DC)) {
1554 }
else if (!AllowLambda && isa<CXXMethodDecl>(DC) &&
1555 cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
1556 cast<CXXRecordDecl>(DC->
getParent())->isLambda()) {
1569 return dyn_cast<FunctionDecl>(DC);
1574 while (isa<RecordDecl>(DC))
1576 return dyn_cast<ObjCMethodDecl>(DC);
1581 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
1582 return cast<NamedDecl>(DC);
1600 if (std::optional<TemplateDeductionInfo *> Info =
isSFINAEContext()) {
1614 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1616 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
1639 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
1641 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
1650 Diag(
Loc, diag::warn_cxx98_compat_sfinae_access_control);
1663 (*Info)->addSuppressedDiagnostic(DiagInfo.
getLocation(),
1693 auto *FD = dyn_cast<FunctionDecl>(
CurContext);
1699 for (
auto PDAt :
Loc->second) {
1715 S.
Diags.
Report(FnIt->second.Loc, diag::note_called_by));
1716 Builder << FnIt->second.FD;
1750class DeferredDiagnosticsEmitter
1768 bool ShouldEmitRootNode;
1773 unsigned InOMPDeviceContext;
1775 DeferredDiagnosticsEmitter(
Sema &S)
1776 : Inherited(S), ShouldEmitRootNode(
false), InOMPDeviceContext(0) {}
1778 bool shouldVisitDiscardedStmt()
const {
return false; }
1781 ++InOMPDeviceContext;
1782 Inherited::VisitOMPTargetDirective(
Node);
1783 --InOMPDeviceContext;
1787 if (isa<VarDecl>(
D))
1789 if (
auto *FD = dyn_cast<FunctionDecl>(
D))
1792 Inherited::visitUsedDecl(
Loc,
D);
1797 "Should only check file-scope variables");
1799 auto DevTy = OMPDeclareTargetDeclAttr::getDeviceType(VD);
1800 bool IsDev = DevTy && (*DevTy == OMPDeclareTargetDeclAttr::DT_NoHost ||
1801 *DevTy == OMPDeclareTargetDeclAttr::DT_Any);
1803 ++InOMPDeviceContext;
1806 --InOMPDeviceContext;
1811 auto &Done = DoneMap[InOMPDeviceContext > 0 ? 1 : 0];
1812 FunctionDecl *Caller = UsePath.empty() ? nullptr : UsePath.back();
1813 if ((!ShouldEmitRootNode && !S.
getLangOpts().OpenMP && !Caller) ||
1817 if (Caller && S.
LangOpts.OpenMP && UsePath.size() == 1 &&
1818 (ShouldEmitRootNode || InOMPDeviceContext))
1825 if (ShouldEmitRootNode || InOMPDeviceContext)
1826 emitDeferredDiags(FD, Caller);
1829 if (!Done.insert(FD).second)
1831 InUsePath.insert(FD);
1832 UsePath.push_back(FD);
1833 if (
auto *S = FD->
getBody()) {
1837 InUsePath.erase(FD);
1840 void checkRecordedDecl(
Decl *
D) {
1841 if (
auto *FD = dyn_cast<FunctionDecl>(
D)) {
1843 Sema::FunctionEmissionStatus::Emitted;
1846 checkVar(cast<VarDecl>(
D));
1850 void emitDeferredDiags(
FunctionDecl *FD,
bool ShowCallStack) {
1854 bool HasWarningOrError =
false;
1855 bool FirstDiag =
true;
1862 HasWarningOrError |=
1871 if (FirstDiag && HasWarningOrError && ShowCallStack) {
1883 DeclsToCheckForDeferredDiags);
1886 DeclsToCheckForDeferredDiags.empty())
1889 DeferredDiagnosticsEmitter DDE(*
this);
1890 for (
auto *
D : DeclsToCheckForDeferredDiags)
1891 DDE.checkRecordedDecl(
D);
1922 : S(S),
Loc(
Loc), DiagID(DiagID), Fn(Fn),
1923 ShowCallStack(K == K_ImmediateWithCallStack || K == K_Deferred) {
1928 case K_ImmediateWithCallStack:
1929 ImmediateDiag.emplace(
1933 assert(Fn &&
"Must have a function to attach the deferred diag to.");
1935 PartialDiagId.emplace(
Diags.size());
1941Sema::SemaDiagnosticBuilder::SemaDiagnosticBuilder(SemaDiagnosticBuilder &&
D)
1943 ShowCallStack(
D.ShowCallStack), ImmediateDiag(
D.ImmediateDiag),
1944 PartialDiagId(
D.PartialDiagId) {
1946 D.ShowCallStack =
false;
1947 D.ImmediateDiag.reset();
1948 D.PartialDiagId.reset();
1951Sema::SemaDiagnosticBuilder::~SemaDiagnosticBuilder() {
1952 if (ImmediateDiag) {
1957 ImmediateDiag.reset();
1958 if (IsWarningOrError && ShowCallStack)
1961 assert((!PartialDiagId || ShowCallStack) &&
1962 "Must always show call stack for deferred diags.");
1968 FD = FD ? FD : getCurFunctionDecl();
1969 if (LangOpts.OpenMP)
1970 return LangOpts.OpenMPIsTargetDevice
1971 ? OpenMP().diagIfOpenMPDeviceCode(
Loc, DiagID, FD)
1972 : OpenMP().diagIfOpenMPHostCode(
Loc, DiagID, FD);
1975 :
CUDA().DiagIfHostCode(
Loc, DiagID);
1978 return SYCL().DiagIfDeviceCode(
Loc, DiagID);
1985 if (isUnevaluatedContext() || Ty.
isNull())
1992 if (
D && LangOpts.SYCLIsDevice) {
1993 llvm::DenseSet<QualType>
Visited;
1997 Decl *
C = cast<Decl>(getCurLexicalContext());
2001 if (
const auto *MD = dyn_cast<CXXMethodDecl>(
C)) {
2002 if ((MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) &&
2006 if (
const auto *Ctor = dyn_cast<CXXConstructorDecl>(MD))
2007 if (Ctor->isCopyOrMoveConstructor() && Ctor->isTrivial())
2014 ? cast<FunctionDecl>(
C)
2015 : dyn_cast_or_null<FunctionDecl>(
D);
2017 auto CheckDeviceType = [&](
QualType Ty) {
2028 targetDiag(
Loc, PD, FD)
2029 <<
false << 0 <<
false
2037 bool LongDoubleMismatched =
false;
2040 if ((&Sem != &llvm::APFloat::PPCDoubleDouble() &&
2042 (&Sem == &llvm::APFloat::PPCDoubleDouble() &&
2044 LongDoubleMismatched =
true;
2053 !LangOpts.CUDAIsDevice) ||
2054 LongDoubleMismatched) {
2061 if (targetDiag(
Loc, PD, FD)
2063 <<
static_cast<unsigned>(Context.
getTypeSize(Ty)) << Ty
2069 targetDiag(
D->
getLocation(), diag::note_defined_here, FD) <<
D;
2073 auto CheckType = [&](
QualType Ty,
bool IsRetTy =
false) {
2074 if (LangOpts.SYCLIsDevice ||
2075 (LangOpts.OpenMP && LangOpts.OpenMPIsTargetDevice) ||
2076 LangOpts.CUDAIsDevice)
2077 CheckDeviceType(Ty);
2089 <<
false << 0 << Ty <<
false
2095 targetDiag(
D->
getLocation(), diag::note_defined_here, FD) <<
D;
2098 bool IsDouble = UnqualTy == Context.
DoubleTy;
2099 bool IsFloat = UnqualTy == Context.
FloatTy;
2100 if (IsRetTy && !TI.
hasFPReturn() && (IsDouble || IsFloat)) {
2108 <<
false << 0 << Ty <<
true
2114 targetDiag(
D->
getLocation(), diag::note_defined_here, FD) <<
D;
2118 llvm::StringMap<bool> CallerFeatureMap;
2120 RISCV().checkRVVTypeSupport(Ty,
Loc,
D, CallerFeatureMap);
2125 llvm::StringMap<bool> CallerFeatureMap;
2129 Diag(
Loc, diag::err_sve_vector_in_non_sve_target) << Ty;
2132 Diag(
Loc, diag::err_sve_vector_in_non_streaming_function) << Ty;
2139 if (
const auto *FPTy = dyn_cast<FunctionProtoType>(Ty)) {
2140 for (
const auto &ParamTy : FPTy->param_types())
2142 CheckType(FPTy->getReturnType(),
true);
2144 if (
const auto *FNPTy = dyn_cast<FunctionNoProtoType>(Ty))
2145 CheckType(FNPTy->getReturnType(),
true);
2154 loc = getSourceManager().getExpansionLoc(loc);
2158 if (getPreprocessor().getSpelling(loc, buffer) == name) {
2171 for (
Scope *S = getCurScope(); S; S = S->getParent()) {
2185 if (FunctionScopes.empty() && CachedFunctionScope) {
2187 CachedFunctionScope->Clear();
2188 FunctionScopes.push_back(CachedFunctionScope.release());
2192 if (LangOpts.OpenMP)
2193 OpenMP().pushOpenMPFunctionRegion();
2198 BlockScope,
Block));
2199 CapturingFunctionScopes++;
2204 FunctionScopes.push_back(LSI);
2205 CapturingFunctionScopes++;
2211 LSI->AutoTemplateParameterDepth = Depth;
2215 "Remove assertion if intentionally called in a non-lambda context.");
2242 if (!
Result.isInvalid()) {
2262 VarDecl *VD = BC.getVariable();
2263 if (VD->
hasAttr<BlocksAttr>()) {
2272 QualType CapType = BC.getVariable()->getType();
2298 assert(!FunctionScopes.empty() &&
"mismatched push/pop!");
2305 if (LangOpts.OpenMP)
2306 OpenMP().popOpenMPFunctionRegion(
Scope.get());
2310 AnalysisWarnings.IssueWarnings(*WP,
Scope.get(),
D, BlockType);
2312 for (
const auto &PUD :
Scope->PossiblyUnreachableDiags)
2313 Diag(PUD.Loc, PUD.PD);
2320 if (!
Scope->isPlainFunction())
2321 Self->CapturingFunctionScopes--;
2323 if (
Scope->isPlainFunction() && !
Self->CachedFunctionScope)
2330 getCurFunction()->CompoundScopes.push_back(
2336 assert(!CurFunction->
CompoundScopes.empty() &&
"mismatched push/pop");
2342 return getCurFunction()->hasUnrecoverableErrorOccurred();
2346 if (!FunctionScopes.empty())
2347 FunctionScopes.back()->setHasBranchIntoScope();
2351 if (!FunctionScopes.empty())
2352 FunctionScopes.back()->setHasBranchProtectedScope();
2356 if (!FunctionScopes.empty())
2357 FunctionScopes.back()->setHasIndirectGoto();
2361 if (!FunctionScopes.empty())
2362 FunctionScopes.back()->setHasMustTail();
2366 if (FunctionScopes.empty())
2369 auto CurBSI = dyn_cast<BlockScopeInfo>(FunctionScopes.back());
2370 if (CurBSI && CurBSI->TheDecl &&
2371 !CurBSI->TheDecl->Encloses(CurContext)) {
2373 assert(!CodeSynthesisContexts.empty());
2381 if (FunctionScopes.empty())
2384 for (
int e = FunctionScopes.size() - 1; e >= 0; --e) {
2385 if (isa<sema::BlockScopeInfo>(FunctionScopes[e]))
2387 return FunctionScopes[e];
2393 for (
auto *
Scope : llvm::reverse(FunctionScopes)) {
2394 if (
auto *LSI = dyn_cast<sema::LambdaScopeInfo>(
Scope)) {
2395 if (LSI->Lambda && !LSI->Lambda->Encloses(CurContext) &&
2396 LSI->AfterParameterList) {
2400 assert(!CodeSynthesisContexts.empty());
2410 if (FunctionScopes.empty())
2413 auto I = FunctionScopes.rbegin();
2414 if (IgnoreNonLambdaCapturingScope) {
2415 auto E = FunctionScopes.rend();
2416 while (I !=
E && isa<CapturingScopeInfo>(*I) && !isa<LambdaScopeInfo>(*I))
2421 auto *CurLSI = dyn_cast<LambdaScopeInfo>(*I);
2422 if (CurLSI && CurLSI->Lambda && CurLSI->CallOperator &&
2423 !CurLSI->Lambda->Encloses(CurContext) && CurLSI->AfterParameterList) {
2425 assert(!CodeSynthesisContexts.empty());
2436 return (LSI->TemplateParams.size() ||
2437 LSI->GLTemplateParameterList) ? LSI :
nullptr;
2444 if (!LangOpts.RetainCommentsFromSystemHeaders &&
2445 SourceMgr.isInSystemHeader(Comment.
getBegin()))
2451 StringRef MagicMarkerText;
2454 MagicMarkerText =
"///<";
2457 MagicMarkerText =
"/**<";
2462 Diag(Comment.
getBegin(), diag::warn_splice_in_doxygen_comment);
2465 llvm_unreachable(
"if this is an almost Doxygen comment, "
2466 "it should be ordinary");
2468 Diag(Comment.
getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
2476char ExternalSemaSource::ID;
2486 llvm::MapVector<NamedDecl *, SourceLocation> &Undefined) {}
2494 OverloadSet.
clear();
2497 bool IsMemExpr =
false;
2507 Overloads = dyn_cast<UnresolvedMemberExpr>(
E.
IgnoreParens());
2511 bool Ambiguous =
false;
2516 DeclsEnd = Overloads->
decls_end(); it != DeclsEnd; ++it) {
2524 = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
2525 if (OverloadDecl->getMinRequiredArguments() == 0) {
2526 if (!ZeroArgCallReturnTy.
isNull() && !Ambiguous &&
2527 (!IsMV || !(OverloadDecl->isCPUDispatchMultiVersion() ||
2528 OverloadDecl->isCPUSpecificMultiVersion()))) {
2532 ZeroArgCallReturnTy = OverloadDecl->getReturnType();
2533 IsMV = OverloadDecl->isCPUDispatchMultiVersion() ||
2534 OverloadDecl->isCPUSpecificMultiVersion();
2542 return !ZeroArgCallReturnTy.
isNull();
2559 if (
const auto *DeclRef = dyn_cast<DeclRefExpr>(
E.
IgnoreParens())) {
2560 if (
const auto *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
2561 if (Fun->getMinRequiredArguments() == 0)
2562 ZeroArgCallReturnTy = Fun->getReturnType();
2577 if (
const auto *FPT = dyn_cast_if_present<FunctionProtoType>(FunTy)) {
2578 if (FPT->getNumParams() == 0)
2599 unsigned ShownOverloads = 0;
2600 unsigned SuppressedOverloads = 0;
2602 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
2604 ++SuppressedOverloads;
2608 const NamedDecl *Fn = (*It)->getUnderlyingDecl();
2610 if (
const auto *FD = Fn->getAsFunction()) {
2612 !FD->
getAttr<TargetAttr>()->isDefaultVersion())
2615 !FD->
getAttr<TargetVersionAttr>()->isDefaultVersion())
2618 S.
Diag(Fn->getLocation(), diag::note_possible_target_of_call);
2624 if (SuppressedOverloads)
2625 S.
Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
2626 << SuppressedOverloads;
2631 bool (*IsPlausibleResult)(
QualType)) {
2632 if (!IsPlausibleResult)
2637 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
2638 const auto *OverloadDecl = cast<FunctionDecl>(*It);
2639 QualType OverloadResultTy = OverloadDecl->getReturnType();
2640 if (IsPlausibleResult(OverloadResultTy))
2641 PlausibleOverloads.
addDecl(It.getDecl());
2652 return (!isa<CStyleCastExpr>(
E) &&
2653 !isa<UnaryOperator>(
E) &&
2654 !isa<BinaryOperator>(
E) &&
2655 !isa<CXXOperatorCallExpr>(
E));
2659 if (
const auto *UO = dyn_cast<UnaryOperator>(
E))
2660 E = UO->getSubExpr();
2662 if (
const auto *ULE = dyn_cast<UnresolvedLookupExpr>(
E)) {
2663 if (ULE->getNumDecls() == 0)
2666 const NamedDecl *ND = *ULE->decls_begin();
2667 if (
const auto *FD = dyn_cast<FunctionDecl>(ND))
2675 bool (*IsPlausibleResult)(
QualType)) {
2682 if (!isSFINAEContext()) {
2684 if (tryExprAsCall(*
E.get(), ZeroArgCallTy, Overloads) &&
2685 !ZeroArgCallTy.
isNull() &&
2686 (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
2703 E = BuildCallExpr(
nullptr,
E.get(),
Range.
getEnd(), std::nullopt,
2708 if (!ForceComplain)
return false;
2720 Ident_super = &Context.
Idents.
get(
"super");
2726 unsigned OpenMPCaptureLevel) {
2730 ? OpenMP().getOpenMPNestingLevel()
2732 OpenMPCaptureLevel);
2733 CSI->ReturnType = Context.
VoidTy;
2734 FunctionScopes.push_back(CSI);
2735 CapturingFunctionScopes++;
2739 if (FunctionScopes.empty())
2742 return dyn_cast<CapturedRegionScopeInfo>(FunctionScopes.back());
2745const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
2751 : S(S), OldFPFeaturesState(S.CurFPFeatures),
2752 OldOverrides(S.FpPragmaStack.CurrentValue),
2753 OldEvalMethod(S.PP.getCurrentFPEvalMethod()),
2754 OldFPPragmaLocation(S.PP.getLastFPEvalPragmaLocation()) {}
2763 assert(
D.getCXXScopeSpec().isSet() &&
2764 "can only be called for qualified names");
2769 !
D.getDeclSpec().isFriendSpecified());
2774 bool Result = llvm::all_of(LR, [](
Decl *Dcl) {
2775 if (
NamedDecl *ND = dyn_cast<NamedDecl>(Dcl)) {
2776 ND = ND->getUnderlyingDecl();
2777 return isa<FunctionDecl>(ND) || isa<FunctionTemplateDecl>(ND) ||
2795 if (POld == OldEnd) {
2799 }
else if (PNew == NewEnd)
2826 }
else if (cmp > 0) {
2843 switch (EffectKind) {
2847 if (DiffKind == Kind::Added) {
2848 for (
const auto &CFE : SrcFX) {
2861 case Kind::ConditionMismatch:
2874 llvm_unreachable(
"unknown effect kind");
2880 switch (EffectKind) {
2889 case Kind::ConditionMismatch:
2899 llvm_unreachable(
"unknown effect kind");
2906 switch (EffectKind) {
2913 return OverrideResult::NoAction;
2917 return OverrideResult::Merge;
2921 case Kind::ConditionMismatch:
2922 return OverrideResult::Warn;
2927 return OverrideResult::NoAction;
2932 llvm_unreachable(
"unknown effect kind");
Defines the clang::ASTContext interface.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
Defines the clang::Expr interface and subclasses for C++ expressions.
llvm::DenseSet< const void * > Visited
llvm::MachO::FileType FileType
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream.
Defines the clang::Preprocessor interface.
This file declares semantic analysis functions specific to AMDGPU.
This file declares semantic analysis functions specific to ARM.
This file declares semantic analysis functions specific to AVR.
This file declares semantic analysis functions specific to BPF.
This file declares semantic analysis for CUDA constructs.
This file declares facilities that support code completion.
This file declares semantic analysis for HLSL constructs.
This file declares semantic analysis functions specific to Hexagon.
This file declares semantic analysis functions specific to LoongArch.
This file declares semantic analysis functions specific to M68k.
This file declares semantic analysis functions specific to MIPS.
This file declares semantic analysis functions specific to MSP430.
This file declares semantic analysis functions specific to NVPTX.
This file declares semantic analysis for Objective-C.
This file declares semantic analysis for OpenACC constructs and clauses.
This file declares semantic analysis routines for OpenCL.
This file declares semantic analysis for OpenMP constructs and clauses.
This file declares semantic analysis functions specific to PowerPC.
This file declares semantic analysis for expressions involving.
This file declares semantic analysis functions specific to RISC-V.
This file declares semantic analysis for SYCL constructs.
This file declares semantic analysis functions specific to Swift.
This file declares semantic analysis functions specific to SystemZ.
This file declares semantic analysis functions specific to Wasm.
This file declares semantic analysis functions specific to X86.
static void checkEscapingByref(VarDecl *VD, Sema &S)
static bool IsCPUDispatchCPUSpecificMultiVersion(const Expr *E)
llvm::DenseMap< const CXXRecordDecl *, bool > RecordCompleteMap
static bool IsCallableWithAppend(const Expr *E)
Determine whether the given expression can be called by just putting parentheses after it.
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...
static void noteOverloads(Sema &S, const UnresolvedSetImpl &Overloads, const SourceLocation FinalNoteLoc)
Give notes for a set of overloads.
static bool isFunctionOrVarDeclExternC(const NamedDecl *ND)
static void markEscapingByrefs(const FunctionScopeInfo &FSI, Sema &S)
static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D)
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
static void emitCallStackNotes(Sema &S, const FunctionDecl *FD)
static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
static void checkUndefinedButUsed(Sema &S)
checkUndefinedButUsed - Check for undefined objects with internal linkage or that are inline.
static bool IsRecordFullyDefined(const CXXRecordDecl *RD, RecordCompleteMap &RecordsComplete, RecordCompleteMap &MNCComplete)
Returns true, if the given CXXRecordDecl is fully defined in this translation unit,...
Defines the SourceManager interface.
Defines utilities for dealing with stack allocation and stack space.
Allows QualTypes to be sorted and hence used in maps and sets.
ASTConsumer - This is an abstract interface that should be implemented by clients that read ASTs.
virtual void CompleteTentativeDefinition(VarDecl *D)
CompleteTentativeDefinition - Callback invoked at the end of a translation unit to notify the consume...
virtual ASTMutationListener * GetASTMutationListener()
If the consumer is interested in entities getting modified after their initial creation,...
virtual void CompleteExternalDeclaration(DeclaratorDecl *D)
CompleteExternalDeclaration - Callback invoked at the end of a translation unit to notify the consume...
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
SourceManager & getSourceManager()
TranslationUnitDecl * getTranslationUnitDecl() const
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type.
TypedefDecl * getCFConstantStringDecl() const
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
TypedefDecl * getBuiltinMSVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_ms_va_list type.
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ArrayRef< Decl * > getModuleInitializers(Module *M)
Get the initializations to perform when importing a module, if any.
void addComment(const RawComment &RC)
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=RecordDecl::TagKind::Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type.
const LangOptions & getLangOpts() const
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
PartialDiagnostic::DiagStorageAllocator & getDiagAllocator()
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
const TargetInfo * getAuxTargetInfo() const
CanQualType UnsignedLongTy
bool hasAnyFunctionEffects() const
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
CanQualType BoundMemberTy
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
LangAS getDefaultOpenCLPointeeAddrSpace()
Returns default address space based on OpenCL version and enabled features.
CanQualType OCLClkEventTy
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
const clang::PrintingPolicy & getPrintingPolicy() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type.
CanQualType UnsignedIntTy
CanQualType OCLReserveIDTy
const TargetInfo & getTargetInfo() const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
void setBlockVarCopyInit(const VarDecl *VD, Expr *CopyExpr, bool CanThrow)
Set the copy initialization expression of a block var decl.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any.
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
IdentifierInfo * getBoolName() const
Retrieve the identifier 'bool'.
void setPrintingPolicy(const clang::PrintingPolicy &Policy)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
A class which contains all the information about a particular captured value.
Represents a block literal declaration, which is like an unnamed FunctionDecl.
ArrayRef< Capture > captures() const
SourceLocation getCaretLocation() const
bool doesNotEscape() const
Represents a C++ destructor within a class.
CXXFieldCollector - Used to keep track of CXXFieldDecls during parsing of C++ classes.
Represents a static or instance method of a struct/union/class.
An iterator over the friend declarations of a class.
Represents a C++ struct/union/class.
friend_iterator friend_begin() const
friend_iterator friend_end() const
Represents the body of a CapturedStmt, and serves as its DeclContext.
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
const char * getCastKindName() const
Abstract interface for a consumer of code-completion information.
The information about the darwin SDK that was used during this compilation.
decl_iterator - Iterates through the declarations stored within this context.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
decl_iterator decls_end() const
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
decl_iterator decls_begin() const
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration,...
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
bool isReferenced() const
Whether any declaration of this entity was referenced.
bool isInvalidDecl() const
SourceLocation getLocation() const
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required.
DeclContext * getDeclContext()
SourceLocation getBeginLoc() const LLVM_READONLY
The name of a declaration.
Represents a ValueDecl that came out of a declarator.
Information about one declarator, including the parsed type information and the identifier.
A little helper class used to produce diagnostics.
static SFINAEResponse getDiagnosticSFINAEResponse(unsigned DiagID)
Determines whether the given built-in diagnostic ID is for an error that is suppressed if it occurs d...
static bool isDefaultMappingAsError(unsigned DiagID)
Return true if the specified diagnostic is mapped to errors by default.
static bool isBuiltinNote(unsigned DiagID)
Determine whether the given built-in diagnostic ID is a Note.
@ SFINAE_SubstitutionFailure
The diagnostic should not be reported, but it should cause template argument deduction to fail.
@ SFINAE_Suppress
The diagnostic should be suppressed entirely.
@ SFINAE_AccessControl
The diagnostic is an access-control diagnostic, which will be substitution failures in some contexts ...
@ SFINAE_Report
The diagnostic should be reported.
A little helper class (which is basically a smart pointer that forwards info from DiagnosticsEngine) ...
const SourceLocation & getLocation() const
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
bool hasErrorOccurred() const
void overloadCandidatesShown(unsigned N)
Call this after showing N overload candidates.
void setLastDiagnosticIgnored(bool Ignored)
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed,...
unsigned getNumOverloadCandidatesToShow() const
When a call or operator fails, print out up to this many candidate overloads as suggestions.
SourceLocation getCurrentDiagLoc() const
void Clear()
Clear out the current diagnostic.
bool hasFatalErrorOccurred() const
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
Level getDiagnosticLevel(unsigned DiagID, SourceLocation Loc) const
Based on the way the client configured the DiagnosticsEngine object, classify the specified diagnosti...
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
bool getSuppressSystemWarnings() const
unsigned getCurrentDiagID() const
Expr * getCondition() const
RAII object that enters a new expression evaluation context.
This represents one expression.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParenImpCasts() LLVM_READONLY
Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...
Expr * IgnoreImplicit() LLVM_READONLY
Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
An abstract interface that should be implemented by external AST sources that also provide informatio...
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.
virtual void ReadUndefinedButUsed(llvm::MapVector< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage,...
~ExternalSemaSource() override
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...
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 > > &)
Represents difference between two FPOptions values.
Represents a member of a struct/union/class.
StringRef getName() const
The name of this FileEntry.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
llvm::vfs::FileSystem & getVirtualFileSystem() const
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string.
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.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
bool isCPUSpecificMultiVersion() const
True if this function is a multiversioned processor specific function as a part of the cpu_specific/c...
bool isDeleted() const
Whether this function has been deleted.
bool isCPUDispatchMultiVersion() const
True if this function is a multiversioned dispatch function as a part of the cpu_specific/cpu_dispatc...
bool isDefaulted() const
Whether this function is defaulted.
const ASTTemplateArgumentListInfo * getTemplateSpecializationArgsAsWritten() const
Retrieve the template argument list as written in the sources, if any.
Support iteration in parallel through a pair of FunctionEffect and EffectConditionExpr containers.
Kind kind() const
The kind of the effect.
An immutable set of FunctionEffects and possibly conditions attached to them.
static FunctionEffectsRef get(QualType QT)
Extract the effects from a Type if it is a function, block, or member function pointer,...
Represents a prototype with parameter type info, e.g.
Declaration of a template function.
FunctionType - C99 6.7.5.3 - Function Declarators.
QualType getReturnType() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
iterator begin(DeclarationName Name)
Returns an iterator over decls with the name 'Name'.
iterator end()
Returns the end iterator.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)
Represents a C array with an unspecified size.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type)
@ CMK_HeaderUnit
Compiling a module header unit.
@ CMK_ModuleInterface
Compiling a C++ modules interface unit.
bool IsHeaderFile
Indicates whether the front-end is explicitly told that the input is a header file (i....
CommentOptions CommentOpts
Options for parsing comments.
unsigned getOpenCLCompatibleVersion() const
Return the OpenCL version that kernel language is compatible with.
void erase(iterator From, iterator To)
iterator begin(Source *source, bool LocalOnly=false)
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.
Represents the results of name lookup.
Encapsulates the data about a macro definition (e.g.
Abstract interface for a module loader.
bool resolveExports(Module *Mod, bool Complain)
Resolve all of the unresolved exports in the given module.
bool resolveConflicts(Module *Mod, bool Complain)
Resolve all of the unresolved conflicts in the given module.
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
Describes a module or submodule.
bool isNamedModuleInterfaceHasInit() const
bool isInterfaceOrPartition() const
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
llvm::iterator_range< submodule_iterator > submodules()
@ PrivateModuleFragment
This is the private module fragment within some C++ module.
@ ExplicitGlobalModuleFragment
This is the explicit Global Module Fragment of a modular TU.
An abstract interface that should be implemented by external AST sources that also provide informatio...
static const unsigned NumNSNumberLiteralMethods
This represents a decl that may have a name.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
bool isExternallyVisible() const
This represents '#pragma omp target' directive.
ObjCMethodDecl - Represents an instance or class method declaration.
void addSupport(const llvm::StringMap< bool > &FeaturesMap, const LangOptions &Opts)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
decls_iterator decls_begin() const
decls_iterator decls_end() const
This interface provides a way to observe the actions of the preprocessor as it does its thing.
unsigned getDiagID() const
void Emit(const DiagnosticBuilder &DB) const
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isIncrementalProcessingEnabled() const
Returns true if incremental processing is enabled.
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
LangOptions::FPEvalMethodKind getCurrentFPEvalMethod() const
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with this preprocessor.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
IdentifierInfo * getIdentifierInfo(StringRef Name) const
Return information about the specified preprocessor identifier token.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
void setCurrentFPEvalMethod(SourceLocation PragmaLoc, LangOptions::FPEvalMethodKind Val)
FileManager & getFileManager() const
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
HeaderSearch & getHeaderSearchInfo() const
const LangOptions & getLangOpts() const
A (possibly-)qualified type.
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...
bool isNull() const
Return true if this QualType doesn't point to a type yet.
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...
QualType getCanonicalType() const
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
bool isConstQualified() const
Determine whether this type is const-qualified.
Represents a struct/union/class.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
Scope - A scope is a transient data structure that is used while parsing the program.
@ TemplateParamScope
This is a scope that corresponds to the template parameters of a C++ template.
@ DeclScope
This is a scope that can contain a declaration.
Smart pointer class that efficiently represents Objective-C method names.
A generic diagnostic builder for errors which may or may not be deferred.
@ K_Immediate
Emit the diagnostic immediately (i.e., behave like Sema::Diag()).
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID, bool DeferHint=false)
Emit a diagnostic.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
const LangOptions & getLangOpts() const
DiagnosticsEngine & getDiagnostics() const
llvm::DenseMap< CanonicalDeclPtr< const FunctionDecl >, FunctionDeclAndLoc > DeviceKnownEmittedFns
An inverse call graph, mapping known-emitted functions to one of their known-emitted callers (plus th...
An abstract interface that should be implemented by clients that read ASTs and then require further s...
void DiagnoseAvailabilityViolations(TranslationUnitDecl *TU)
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
void DiagnoseUseOfUnimplementedSelectors()
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
void DiagnoseUnterminatedOpenMPDeclareTarget()
Report unterminated 'omp declare target' or 'omp begin declare target' at the end of a compilation un...
void finalizeOpenMPDelayedAnalysis(const FunctionDecl *Caller, const FunctionDecl *Callee, SourceLocation Loc)
Finishes analysis of the deferred functions calls that may be declared as host/nohost during device/h...
A class which encapsulates the logic for delaying diagnostics during parsing and other processing.
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
FPFeaturesStateRAII(Sema &S)
Custom deleter to allow FunctionScopeInfos to be kept alive for a short time after they've been poppe...
void operator()(sema::FunctionScopeInfo *Scope) const
RAII class used to indicate that we are performing provisional semantic analysis to determine the val...
Sema - This implements semantic analysis and AST building for C.
SmallVector< DeclaratorDecl *, 4 > ExternalDeclarations
All the external declarations encoutered and used in the TU.
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
bool isExternalWithNoLinkageType(const ValueDecl *VD) const
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
@ LookupOrdinaryName
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....
void addImplicitTypedef(StringRef Name, QualType T)
void CheckDelegatingCtorCycles()
SmallVector< CXXMethodDecl *, 4 > DelayedDllExportMemberFunctions
const TranslationUnitKind TUKind
The kind of translation unit we are processing.
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
void emitAndClearUnusedLocalTypedefWarnings()
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
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.
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
llvm::DenseSet< std::pair< Decl *, unsigned > > InstantiatingSpecializations
Specializations whose definitions are currently being instantiated.
PragmaStack< FPOptionsOverride > FpPragmaStack
void setFunctionHasBranchIntoScope()
virtual void anchor()
This virtual key function only exists to limit the emission of debug info describing the Sema class.
void ActOnComment(SourceRange Comment)
void ActOnEndOfTranslationUnit()
ActOnEndOfTranslationUnit - This is called at the very end of the translation unit when EOF is reache...
FPOptionsOverride CurFPFeatureOverrides()
void ActOnTranslationUnitScope(Scope *S)
Scope actions.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Look up a name, looking for a single declaration.
IdentifierInfo * getSuperIdentifier() const
FunctionDecl * getCurFunctionDecl(bool AllowLambda=false) const
Returns a pointer to the innermost enclosing function, or nullptr if the current context is not insid...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one.
DiagnosticsEngine & getDiagnostics() const
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.
SemaDiagnosticBuilder::DeferredDiagnosticsType DeviceDeferredDiags
Diagnostics that are emitted only if we discover that the given function must be codegen'ed.
void CheckDelayedMemberExceptionSpecs()
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used.
ASTContext & getASTContext() const
SmallVector< std::pair< FunctionDecl *, FunctionDecl * >, 2 > DelayedEquivalentExceptionSpecChecks
All the function redeclarations seen during a class definition that had their exception spec checks d...
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_PRValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CheckedConversionKind::Implicit)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
static const unsigned MaxAlignmentExponent
The maximum alignment, same as in llvm::Value.
bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee)
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy for diagnostics.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
sema::LambdaScopeInfo * getCurGenericLambda()
Retrieve the current generic lambda info, if any.
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
void setFunctionHasIndirectGoto()
LangAS getDefaultCXXMethodAddrSpace() const
Returns default addr space for method qualifiers.
void PushFunctionScope()
Enter a new function scope.
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted.
std::unique_ptr< sema::FunctionScopeInfo, PoppedFunctionScopeDeleter > PoppedFunctionScopePtr
Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer, TranslationUnitKind TUKind=TU_Complete, CodeCompleteConsumer *CompletionConsumer=nullptr)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
sema::LambdaScopeInfo * PushLambdaScope()
const LangOptions & getLangOpts() const
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
ASTConsumer & getASTConsumer() const
threadSafety::BeforeSet * ThreadSafetyDeclCache
void checkTypeSupport(QualType Ty, SourceLocation Loc, ValueDecl *D=nullptr)
Check if the type is allowed to be used for the current target.
const LangOptions & LangOpts
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
static const uint64_t MaximumAlignment
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
void ActOnEndOfTranslationUnitFragment(TUFragmentKind Kind)
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
IdentifierInfo * InventAbbreviatedTemplateParameterTypeName(const IdentifierInfo *ParamName, unsigned Index)
Invent a new identifier for parameters of abbreviated templates.
SmallVector< PendingImplicitInstantiation, 1 > LateParsedInstantiations
Queue of implicit template instantiations that cannot be performed eagerly.
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...
NamedDecl * getCurFunctionOrMethodDecl() const
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in,...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
void PushCompoundScope(bool IsStmtExpr)
bool isDeclaratorFunctionLike(Declarator &D)
Determine whether.
std::optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
FunctionEmissionStatus getEmissionStatus(const FunctionDecl *Decl, bool Final=false)
Module * getCurrentModule() const
Get the module unit whose scope we are currently within.
static bool isCast(CheckedConversionKind CCK)
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
DeclContext * getFunctionLevelDeclContext(bool AllowLambda=false) const
If AllowLambda is true, treat lambda as function.
bool DefineUsedVTables()
Define all of the vtables that have been used in this translation unit and reference any virtual memb...
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
SourceManager & getSourceManager() const
bool makeUnavailableInSystemHeader(SourceLocation loc, UnavailableAttr::ImplicitReason reason)
makeUnavailableInSystemHeader - There is an error in the current context.
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
void diagnoseFunctionEffectConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn when implicitly changing function effects.
ExprResult PerformMoveOrCopyInitialization(const InitializedEntity &Entity, const NamedReturnInfo &NRInfo, Expr *Value, bool SupressSimplerImplicitMoves=false)
Perform the initialization of a potentially-movable value, which is the result of return value.
void DiagnoseNonDefaultPragmaAlignPack(PragmaAlignPackDiagnoseKind Kind, SourceLocation IncludeLoc)
CanThrowResult canThrow(const Stmt *E)
bool AccessCheckingSFINAE
When true, access checking violations are treated as SFINAE failures rather than hard errors.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K, unsigned OpenMPCaptureLevel=0)
void setFunctionHasMustTail()
bool WarnedStackExhausted
void CheckCompleteVariableDeclaration(VarDecl *VD)
@ Global
The global module fragment, between 'module;' and a module-declaration.
@ Private
The private module fragment, between 'module :private;' and the end of the translation unit.
@ Normal
A normal translation unit fragment.
void setFunctionHasBranchProtectedScope()
RedeclarationKind forRedeclarationInCurContext() const
void ActOnStartOfTranslationUnit()
This is called before the very first declaration in the translation unit is parsed.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
@ NonDefaultStateAtInclude
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
bool hasUncompilableErrorOccurred() const
Whether uncompilable error has occurred.
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.
@ PotentiallyEvaluated
The current expression is potentially evaluated at run time, which means that code may be generated t...
std::pair< SourceLocation, bool > DeleteExprLoc
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing.
bool RequireCompleteType(SourceLocation Loc, QualType T, CompleteTypeKind Kind, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void DiagnoseUnterminatedPragmaAttribute()
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Delete-expressions to be analyzed at the end of translation unit.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups,...
DarwinSDKInfo * getDarwinSDKInfoForAvailabilityChecking()
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retrieves list of suspicious delete-expressions that will be checked at the end of translation unit.
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
SourceManager & SourceMgr
DiagnosticsEngine & Diags
void DiagnoseUnterminatedPragmaAlignPack()
OpenCLOptions & getOpenCLOptions()
LateTemplateParserCleanupCB * LateTemplateParserCleanup
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
void PrintStats() const
Print out statistics about the semantic analysis.
llvm::BumpPtrAllocator BumpAlloc
sema::LambdaScopeInfo * getEnclosingLambda() const
Get the innermost lambda enclosing the current location, if any.
void runWithSufficientStackSpace(SourceLocation Loc, llvm::function_ref< void()> Fn)
Run some code with "sufficient" stack space.
void addExternalSource(ExternalSemaSource *E)
Registers an external source.
SmallVector< CXXRecordDecl *, 4 > DelayedDllExportClasses
llvm::MapVector< IdentifierInfo *, llvm::SetVector< WeakInfo, llvm::SmallVector< WeakInfo, 1u >, llvm::SmallDenseSet< WeakInfo, 2u, WeakInfo::DenseMapInfoByAliasOnly > > > WeakUndeclaredIdentifiers
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID, const FunctionDecl *FD=nullptr)
DeclarationName VAListTagName
VAListTagName - The declaration name corresponding to __va_list_tag.
sema::FunctionScopeInfo * getEnclosingFunction() const
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
void warnStackExhausted(SourceLocation Loc)
Warn that the stack is nearly exhausted.
void diagnoseZeroToNullptrConversion(CastKind Kind, const Expr *E)
Warn when implicitly casting 0 to nullptr.
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...
IdentifierResolver IdResolver
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
ASTMutationListener * getASTMutationListener() const
Encodes a location in the source.
bool isValid() const
Return true if this is a valid SourceLocation object.
SourceLocation getLocWithOffset(IntTy Offset) const
Return a source location with the specified offset from this SourceLocation.
This class handles loading and caching of source files into memory.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID.
A trivial tuple used to represent a source range.
SourceLocation getEnd() const
SourceLocation getBegin() const
void setEnd(SourceLocation e)
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
SourceLocation getBeginLoc() const LLVM_READONLY
bool isCompleteDefinition() const
Return true if this decl has its body fully specified.
Exposes information about the current target.
virtual bool hasLongDoubleType() const
Determine whether the long double type is supported on this target.
virtual bool hasBitIntType() const
Determine whether the _BitInt type is supported on this target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
virtual bool hasFloat16Type() const
Determine whether the _Float16 type is supported on this target.
llvm::StringMap< bool > & getSupportedOpenCLOpts()
Get supported OpenCL extensions and optional core features.
virtual bool hasIbm128Type() const
Determine whether the __ibm128 type is supported on this target.
virtual bool hasFPReturn() const
Determine whether return of a floating point value is supported on this target.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
virtual bool hasFloat128Type() const
Determine whether the __float128 type is supported on this target.
bool hasAArch64SVETypes() const
Returns whether or not the AArch64 SVE built-in types are available on this target.
virtual bool hasBFloat16Type() const
Determine whether the _BFloat16 type is supported on this target.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool hasRISCVVTypes() const
Returns whether or not the RISC-V V built-in types are available on this target.
A container of type source information.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isFloat16Type() const
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool isSVESizelessBuiltinType() const
Returns true for SVE scalable vector types.
bool isFloat128Type() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.
bool isBitIntType() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
bool isIbm128Type() const
bool isBFloat16Type() const
bool isStructureOrClassType() const
bool isRealFloatingType() const
Floating point categories.
bool isRVVSizelessBuiltinType() const
Returns true for RVV scalable vector types.
Linkage getLinkage() const
Determine the linkage of this type.
const T * getAs() const
Member-template getAs<specific type>'.
bool isNullPtrType() const
std::optional< NullabilityKind > getNullability() const
Determine the nullability of the given type.
Base class for declarations which introduce a typedef-name.
Simple class containing the result of Sema::CorrectTypo.
A set of unresolved declarations.
void addDecl(NamedDecl *D)
The iterator over UnresolvedSets.
A set of unresolved declarations.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
void setType(QualType newType)
Represents a variable declaration or definition.
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
bool isFileVarDecl() const
Returns true for file scoped variable declaration.
const Expr * getInit() const
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
@ DeclarationOnly
This declaration is only a declaration.
bool isEscapingByref() const
Indicates the capture is a __block variable that is captured by a block that can potentially escape (...
Declaration of a variable template.
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, QualType BlockType)
Retains information about a block that is currently being parsed.
Retains information about a captured region.
Contains information about the compound statement currently being parsed.
Retains information about a function, method, or block that is currently being parsed.
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound statement scopes in the function.
llvm::SmallPtrSet< const BlockDecl *, 1 > Blocks
The set of blocks that are introduced in this function.
llvm::TinyPtrVector< VarDecl * > ByrefBlockVars
The set of __block variables that are introduced in this function.
void FileChanged(SourceLocation Loc, FileChangeReason Reason, SrcMgr::CharacteristicKind FileType, FileID PrevFID) override
Callback invoked whenever a source file is entered or exited.
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
void threadSafetyCleanup(BeforeSet *Cache)
The JSON file list parser is used to communicate input to InstallAPI.
@ Self
'self' clause, allowed on Compute and Combined Constructs, plus 'update'.
@ ExpectedVariableOrFunction
@ Nullable
Values of this type can be null.
@ NonNull
Values of this type can never be null.
Expected< std::optional< DarwinSDKInfo > > parseDarwinSDKInfo(llvm::vfs::FileSystem &VFS, StringRef SDKRootPath)
Parse the SDK information from the SDKSettings.json file.
CapturedRegionKind
The different kinds of captured statement.
@ Result
The result type of a method or function.
@ Class
The "class" keyword.
LangAS
Defines the address space values used by the address space qualifier of QualType.
CastKind
CastKind - The kind of operation required for a conversion.
TranslationUnitKind
Describes the kind of translation unit being processed.
@ TU_ClangModule
The translation unit is a clang module.
@ TU_Prefix
The translation unit is a prefix to a translation unit, and is not complete.
ComparisonCategoryType
An enumeration representing the different comparison categories types.
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.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
@ VK_XValue
An x-value expression is a reference to an object with independent storage but which can be "moved",...
@ VK_LValue
An l-value expression is a reference to an object with independent storage.
const FunctionProtoType * T
bool isExternalFormalLinkage(Linkage L)
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs.
@ Class
The "class" keyword introduces the elaborated-type-specifier.
bool IsArmStreamingFunction(const FunctionDecl *FD, bool IncludeLocallyStreaming)
Returns whether the given FunctionDecl has an __arm[_locally]_streaming attribute.
void runWithSufficientStackSpace(llvm::function_ref< void()> Diag, llvm::function_ref< void()> Fn)
Run a given function on a stack with "sufficient" space.
bool isExternallyVisible(Linkage L)
CheckedConversionKind
The kind of conversion being performed.
Represents an explicit template argument list in C++, e.g., the "<int>" in "sort<int>".
bool shouldDiagnoseConversion(QualType SrcType, const FunctionEffectsRef &SrcFX, QualType DstType, const FunctionEffectsRef &DstFX) const
Return true if adding or removing the effect as part of a type conversion should generate a diagnosti...
OverrideResult
Describes the result of effects differing between a base class's virtual method and an overriding met...
OverrideResult shouldDiagnoseMethodOverride(const CXXMethodDecl &OldMethod, const FunctionEffectsRef &OldFX, const CXXMethodDecl &NewMethod, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a C++ virtual method override should generate a diagn...
bool shouldDiagnoseRedeclaration(const FunctionDecl &OldFunction, const FunctionEffectsRef &OldFX, const FunctionDecl &NewFunction, const FunctionEffectsRef &NewFX) const
Return true if adding or removing the effect in a redeclaration should generate a diagnostic.
FunctionEffectDifferences(const FunctionEffectsRef &Old, const FunctionEffectsRef &New)
Caller should short-circuit by checking for equality first.
A FunctionEffect plus a potential boolean expression determining whether the effect is declared (e....
bool HasFormOfMemberPointer
OverloadExpr * Expression
Describes how types, statements, expressions, and declarations should be printed.
unsigned Bool
Whether we can use 'bool' rather than '_Bool' (even if the language doesn't actually have 'bool',...
unsigned EntireContentsOfLargeArray
Whether to print the entire array initializers, especially on non-type template parameters,...
@ RewritingOperatorAsSpaceship
We are rewriting a comparison operator in terms of an operator<=>.