40 #include "llvm/ADT/APFloat.h"
41 #include "llvm/ADT/DenseMap.h"
42 #include "llvm/ADT/SmallSet.h"
43 #include "llvm/Support/CrashRecoveryContext.h"
44 using namespace clang;
60 Policy.
Bool = BoolMacro->isObjectLike() &&
61 BoolMacro->getNumTokens() == 1 &&
62 BoolMacro->getReplacementToken(0).is(tok::kw__Bool);
77 : ExternalSource(nullptr),
78 isMultiplexExternalSource(
false), FPFeatures(pp.getLangOpts()),
79 LangOpts(pp.getLangOpts()), PP(pp),
Context(ctxt), Consumer(consumer),
80 Diags(PP.getDiagnostics()),
SourceMgr(PP.getSourceManager()),
81 CollectStats(
false), CodeCompleter(CodeCompleter),
82 CurContext(nullptr), OriginalLexicalContext(nullptr),
83 PackContext(nullptr), MSStructPragmaOn(
false),
84 MSPointerToMemberRepresentationMethod(
85 LangOpts.getMSPointerToMemberRepresentationMethod()),
86 VtorDispModeStack(1, MSVtorDispAttr::Mode(LangOpts.VtorDispMode)),
87 DataSegStack(nullptr), BSSSegStack(nullptr), ConstSegStack(nullptr),
88 CodeSegStack(nullptr), CurInitSeg(nullptr), VisContext(nullptr),
89 IsBuildingRecoveryCallExpr(
false),
90 ExprNeedsCleanups(
false), LateTemplateParser(nullptr),
91 LateTemplateParserCleanup(nullptr),
92 OpaqueParser(nullptr), IdResolver(pp), StdInitializerList(nullptr),
93 CXXTypeInfoDecl(nullptr), MSVCGuidDecl(nullptr),
94 NSNumberDecl(nullptr), NSValueDecl(nullptr),
95 NSStringDecl(nullptr), StringWithUTF8StringMethod(nullptr),
96 ValueWithBytesObjCTypeMethod(nullptr),
97 NSArrayDecl(nullptr), ArrayWithObjectsMethod(nullptr),
98 NSDictionaryDecl(nullptr), DictionaryWithObjectsMethod(nullptr),
99 MSAsmLabelNameCounter(0),
100 GlobalNewDeleteDeclared(
false),
103 CachedFakeTopLevelModule(nullptr),
104 AccessCheckingSFINAE(
false), InNonInstantiationSFINAEContext(
false),
105 NonInstantiationEntries(0), ArgumentPackSubstitutionIndex(-1),
106 CurrentInstantiationScope(nullptr), DisableTypoCorrection(
false),
107 TyposCorrected(0), AnalysisWarnings(*this), ThreadSafetyDeclCache(nullptr),
108 VarDataSharingAttributesStack(nullptr), CurScope(nullptr),
109 Ident_super(nullptr), Ident___float128(nullptr)
113 LoadedExternalKnownNamespaces =
false;
132 InitDataSharingAttributesStack();
147 SC->InitializeSema(*
this);
152 ExternalSema->InitializeSema(*
this);
264 ExternalSema->ForgetSema();
267 if (isMultiplexExternalSource)
268 delete ExternalSource;
273 DestroyDataSharingAttributesStack();
275 assert(DelayedTypos.empty() &&
"Uncorrected typos!");
286 if (!fn)
return false;
297 if (fn->
hasAttr<UnavailableAttr>())
return true;
313 assert(E &&
"Cannot use with NULL ptr");
315 if (!ExternalSource) {
320 if (isMultiplexExternalSource)
324 isMultiplexExternalSource =
true;
330 llvm::errs() <<
"\n*** Semantic Analysis Stats:\n";
348 llvm_unreachable(
"can't implicitly cast lvalue to rvalue with this cast "
366 Diag(E->getLocStart(), diag::warn_nullability_lost)
376 if (ExprTy == TypeTy)
380 if (ImpCast->getCastKind() == Kind && (!BasePath || BasePath->empty())) {
382 ImpCast->setValueKind(VK);
415 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
419 if (FD->hasBody(DeclToCheck))
425 if (DeclToCheck != FD)
429 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
435 if (VD->isReferenced() &&
436 VD->isUsableInConstantExpressions(SemaRef->
Context))
448 if (DeclToCheck != VD)
458 for (llvm::DenseMap<NamedDecl *, SourceLocation>::iterator
467 if (ND->
hasAttr<WeakRefAttr>())
continue;
472 if (FD->isExternallyVisible() &&
473 !FD->getMostRecentDecl()->isInlined())
482 Undefined.push_back(std::make_pair(ND, I->second));
488 std::sort(Undefined.begin(), Undefined.end(),
489 [&
SM](
const std::pair<NamedDecl *, SourceLocation> &l,
490 const std::pair<NamedDecl *, SourceLocation> &r) {
491 if (l.second.isValid() && !r.second.isValid())
493 if (!l.second.isValid() && r.second.isValid())
495 if (l.second != r.second)
498 r.first->getLocation());
510 if (Undefined.empty())
return;
512 for (
SmallVectorImpl<std::pair<NamedDecl *, SourceLocation> >::iterator
513 I = Undefined.begin(), E = Undefined.end(); I != E; ++I) {
516 if (ND->
hasAttr<DLLImportAttr>() || ND->
hasAttr<DLLExportAttr>()) {
525 << isa<VarDecl>(ND) << ND;
527 assert(cast<FunctionDecl>(ND)->getMostRecentDecl()->isInlined() &&
528 "used object requires definition but isn't inline or internal?");
531 if (I->second.isValid())
532 S.
Diag(I->second, diag::note_used_here);
542 for (
auto &WeakID : WeakIDs)
556 RecordCompleteMap::iterator
Cache = MNCComplete.find(RD);
557 if (Cache != MNCComplete.end())
558 return Cache->second;
561 bool Complete =
true;
564 I != E && Complete; ++I) {
566 Complete = M->isDefined() || (M->isPure() && !isa<CXXDestructorDecl>(M));
572 Complete = !F->getTemplatedDecl()->isLateTemplateParsed() &&
573 F->getTemplatedDecl()->isDefined();
574 else if (
const CXXRecordDecl *R = dyn_cast<CXXRecordDecl>(*I)) {
575 if (R->isInjectedClassName())
577 if (R->hasDefinition())
584 MNCComplete[RD] = Complete;
598 RecordCompleteMap::iterator
Cache = RecordsComplete.find(RD);
599 if (Cache != RecordsComplete.end())
600 return Cache->second;
604 I != E && Complete; ++I) {
608 if (
CXXRecordDecl *FriendD = TSI->getType()->getAsCXXRecordDecl())
615 dyn_cast<FunctionDecl>((*I)->getFriendDecl()))
616 Complete = FD->isDefined();
622 RecordsComplete[RD] = Complete;
631 if (TD->isReferenced())
633 Diag(TD->getLocation(), diag::warn_unused_local_typedef)
634 << isa<TypeAliasDecl>(TD) << TD->getDeclName();
636 UnusedLocalTypedefNameCandidates.clear();
644 &&
"reached end of translation unit with a pool attached?");
670 if (ExternalSource) {
675 Pending.begin(), Pending.end());
708 if (WeakID.second.getUsed())
711 Diag(WeakID.second.getLocation(), diag::warn_weak_identifier_undeclared)
726 Stack.push_back(CurrentModule);
727 while (!Stack.empty()) {
728 Module *Mod = Stack.pop_back_val();
763 llvm::SmallSet<VarDecl *, 32> Seen;
764 for (TentativeDefinitionsType::iterator
786 diag::err_tentative_def_incomplete_type))
801 for (UnusedFileScopedDeclsType::iterator
807 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(*I)) {
809 if (!FD->hasBody(DiagD))
814 if (isa<CXXMethodDecl>(DiagD))
818 if (FD->getStorageClass() ==
SC_Static &&
819 !FD->isInlineSpecified() &&
823 diag::warn_unneeded_static_internal_decl)
831 isa<CXXMethodDecl>(DiagD) ? diag::warn_unused_member_function
832 : diag::warn_unused_function)
838 DiagD = cast<VarDecl>(*I);
879 AnalyzeDeleteExprMismatch(DeletedFieldInfo.first,
DeleteExprLoc.first,
889 "Didn't unmark var as having its initializer parsed");
903 if (isa<BlockDecl>(DC) || isa<EnumDecl>(DC) || isa<CapturedDecl>(DC)) {
905 }
else if (isa<CXXMethodDecl>(DC) &&
906 cast<CXXMethodDecl>(DC)->getOverloadedOperator() == OO_Call &&
907 cast<CXXRecordDecl>(DC->
getParent())->isLambda()) {
926 while (isa<RecordDecl>(DC))
933 if (isa<ObjCMethodDecl>(DC) || isa<FunctionDecl>(DC))
934 return cast<NamedDecl>(DC);
960 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
962 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
985 if (*Info && !(*Info)->hasSFINAEDiagnostic()) {
987 (*Info)->addSFINAEDiagnostic(DiagInfo.
getLocation(),
996 Diag(Loc, diag::warn_cxx98_compat_sfinae_access_control);
1009 (*Info)->addSuppressedDiagnostic(DiagInfo.
getLocation(),
1113 BlockScope, Block));
1124 LSI->AutoTemplateParameterDepth =
Depth;
1128 "Remove assertion if intentionally called in a non-lambda context.");
1141 Diag(PUD.Loc, PUD.PD);
1153 assert(!CurFunction->
CompoundScopes.empty() &&
"mismatched push/pop");
1169 if (CurBSI && CurBSI->TheDecl &&
1184 if (CurLSI && CurLSI->Lambda &&
1197 return (LSI->AutoTemplateParams.size() ||
1198 LSI->GLTemplateParameterList) ? LSI :
nullptr;
1205 if (!
LangOpts.RetainCommentsFromSystemHeaders &&
1213 StringRef MagicMarkerText;
1216 MagicMarkerText =
"///<";
1219 MagicMarkerText =
"/**<";
1222 llvm_unreachable(
"if this is an almost Doxygen comment, "
1223 "it should be ordinary");
1225 Diag(Comment.
getBegin(), diag::warn_not_a_doxygen_trailing_member_comment) <<
1241 llvm::DenseMap<NamedDecl *, SourceLocation> &Undefined) {
1256 if (TheDecl && isa<NamedDecl>(TheDecl)) {
1257 std::string Name = cast<NamedDecl>(TheDecl)->getNameAsString();
1259 OS <<
" '" << Name <<
'\'';
1279 OverloadSet.
clear();
1282 bool IsMemExpr =
false;
1296 bool Ambiguous =
false;
1300 DeclsEnd = Overloads->
decls_end(); it != DeclsEnd; ++it) {
1308 = dyn_cast<FunctionDecl>((*it)->getUnderlyingDecl())) {
1309 if (OverloadDecl->getMinRequiredArguments() == 0) {
1310 if (!ZeroArgCallReturnTy.
isNull() && !Ambiguous) {
1314 ZeroArgCallReturnTy = OverloadDecl->getReturnType();
1321 return !ZeroArgCallReturnTy.
isNull();
1341 if (
const FunctionDecl *Fun = dyn_cast<FunctionDecl>(DeclRef->getDecl())) {
1342 if (Fun->getMinRequiredArguments() == 0)
1343 ZeroArgCallReturnTy = Fun->getReturnType();
1359 dyn_cast_or_null<FunctionProtoType>(FunTy)) {
1360 if (FPT->getNumParams() == 0)
1381 int ShownOverloads = 0;
1382 int SuppressedOverloads = 0;
1384 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
1388 ++SuppressedOverloads;
1397 if (SuppressedOverloads)
1398 S.
Diag(FinalNoteLoc, diag::note_ovl_too_many_candidates)
1399 << SuppressedOverloads;
1404 bool (*IsPlausibleResult)(
QualType)) {
1405 if (!IsPlausibleResult)
1410 DeclsEnd = Overloads.
end(); It != DeclsEnd; ++It) {
1411 const FunctionDecl *OverloadDecl = cast<FunctionDecl>(*It);
1413 if (IsPlausibleResult(OverloadResultTy))
1414 PlausibleOverloads.
addDecl(It.getDecl());
1425 return (!isa<CStyleCastExpr>(E) &&
1426 !isa<UnaryOperator>(E) &&
1427 !isa<BinaryOperator>(E) &&
1428 !isa<CXXOperatorCallExpr>(E));
1433 bool (*IsPlausibleResult)(
QualType)) {
1440 !ZeroArgCallTy.
isNull() &&
1441 (!IsPlausibleResult || IsPlausibleResult(ZeroArgCallTy))) {
1461 if (!ForceComplain)
return false;
1463 Diag(Loc, PD) << 0 << Range;
1476 if (!Ident___float128)
1478 return Ident___float128;
1496 const llvm::MapVector<FieldDecl *, Sema::DeleteLocs> &
void FreePackedContext()
FreePackedContext - Deallocate and null out PackContext.
Defines the clang::ASTContext interface.
SourceLocation getEnd() const
UnusedFileScopedDeclsType UnusedFileScopedDecls
The set of file scoped decls seen so far that have not been used and must warn if not used...
llvm::SmallSetVector< const TypedefNameDecl *, 4 > UnusedLocalTypedefNameCandidates
Set containing all typedefs that are likely unused.
Scope * getCurScope() const
Retrieve the parser's current scope.
IdentifierInfo * getSuperIdentifier() const
Smart pointer class that efficiently represents Objective-C method names.
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
TypedefDecl * getUInt128Decl() const
Retrieve the declaration for the 128-bit unsigned integer type.
CanQualType OCLImage1dBufferTy
void Initialize()
Perform initialization that occurs after the parser has been initialized but before it parses anythin...
LateParsedTemplateMapT LateParsedTemplateMap
DeclContext * getFunctionLevelDeclContext()
static const CastKind CK_Invalid
Defines the clang::FileManager interface and associated types.
RecordDecl * buildImplicitRecord(StringRef Name, RecordDecl::TagKind TK=TTK_Struct) const
Create a new implicit TU-level CXXRecordDecl or RecordDecl declaration.
const LangOptions & getLangOpts() const
void getUndefinedButUsed(SmallVectorImpl< std::pair< NamedDecl *, SourceLocation > > &Undefined)
Obtain a sorted list of functions that are undefined but ODR-used.
submodule_iterator submodule_begin()
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
IdentifierInfo * getIdentifierInfo(StringRef Name) const
The current expression is potentially evaluated at run time, which means that code may be generated t...
static void notePlausibleOverloads(Sema &S, SourceLocation Loc, const UnresolvedSetImpl &Overloads, bool(*IsPlausibleResult)(QualType))
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
Module * getCurrentModule()
Retrieves the module that we're currently building, if any.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
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...
The translation unit is a prefix to a translation unit, and is not complete.
bool hasErrorOccurred() const
virtual void ReadMethodPool(Selector Sel)
Load the contents of the global method pool for a given selector.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
A container of type source information.
IdentifierInfo * getFloat128Identifier() const
The diagnostic should not be reported, but it should cause template argument deduction to fail...
void LoadExternalWeakUndeclaredIdentifiers()
Load weak undeclared identifiers from the external source.
bool resolveUses(Module *Mod, bool Complain)
Resolve all of the unresolved uses in the given module.
Retains information about a function, method, or block that is currently being parsed.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
TypedefDecl * getBuiltinVaListDecl() const
Retrieve the C type declaration corresponding to the predefined __builtin_va_list type...
DiagnosticsEngine & Diags
virtual void ReadWeakUndeclaredIdentifiers(SmallVectorImpl< std::pair< IdentifierInfo *, WeakInfo > > &WI)
Read the set of weak, undeclared identifiers known to the external Sema source.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
Expr * IgnoreImplicit() LLVM_READONLY
Describes how types, statements, expressions, and declarations should be printed. ...
decl_iterator decls_end() const
Defines the clang::Expr interface and subclasses for C++ expressions.
iterator begin(Source *source, bool LocalOnly=false)
iterator begin(DeclarationName Name)
begin - Returns an iterator for decls with the name 'Name'.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
void threadSafetyCleanup(BeforeSet *Cache)
void CheckDelayedMemberExceptionSpecs()
ActiveTemplateInstantiation LastTemplateInstantiationErrorContext
The last template from which a template instantiation error or warning was produced.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
void FreeVisContext()
FreeVisContext - Deallocate and null out VisContext.
ObjCInterfaceDecl * getObjCProtocolDecl() const
Retrieve the Objective-C class declaration corresponding to the predefined Protocol class...
An iterator over the friend declarations of a class.
void PrintInstantiationStack()
Prints the current instantiation stack through a series of notes.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
virtual void ReadUnusedLocalTypedefNameCandidates(llvm::SmallSetVector< const TypedefNameDecl *, 4 > &Decls)
Read the set of potentially unused typedefs known to the source.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
sema::DelayedDiagnosticPool * getCurrentPool() const
Returns the current delayed-diagnostics pool.
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CanQualType OCLImage2dArrayTy
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
QualType getReturnType() const
void erase(iterator From, iterator To)
bool isCompleteDefinition() const
threadSafety::BeforeSet * ThreadSafetyDeclCache
bool isReferenced() const
Whether any declaration of this entity was referenced.
void ActOnEndOfTranslationUnit()
const MacroInfo * getMacroInfo(const IdentifierInfo *II) const
const LangOptions & getLangOpts() const
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...
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.
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...
Converts a floating point complex to bool by comparing against 0+0i.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU. Returns null if there is a pro...
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...
friend_iterator friend_end() const
bool hasUnrecoverableErrorOccurred() const
Determine whether any unrecoverable errors have occurred since this object instance was created...
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
const LangOptions & getLangOpts() const
ObjCMethodDecl * getCurMethodDecl()
bool HasFormOfMemberPointer
const SourceLocation & getLocation() const
unsigned getDiagID() const
QualType getReturnType() const
std::pair< SourceLocation, bool > DeleteExprLoc
Delete-expressions to be analyzed at the end of translation unit.
HeaderSearch & getHeaderSearchInfo() const
void PerformPendingInstantiations(bool LocalOnly=false)
Performs template instantiation for all implicit template instantiations we have seen until this poin...
A set of unresolved declarations.
void IssueWarnings(Policy P, FunctionScopeInfo *fscope, const Decl *D, const BlockExpr *blkExpr)
QualType getIntPtrType() const
Return a type compatible with "intptr_t" (C99 7.18.1.4), as defined by the target.
void CheckDelegatingCtorCycles()
TypedefDecl * getObjCIdDecl() const
Retrieve the typedef corresponding to the predefined id type in Objective-C.
CheckedConversionKind
The kind of conversion being performed.
~ExternalSemaSource() override
Values of this type can never be null.
void addExternalSource(ExternalSemaSource *E)
Registers an external source. If an external source already exists, creates a multiplex external sour...
static const unsigned NumNSNumberLiteralMethods
submodule_iterator submodule_end()
void emitAndClearUnusedLocalTypedefWarnings()
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.
void CheckCompleteVariableDeclaration(VarDecl *var)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
This represents the body of a CapturedStmt, and serves as its DeclContext.
decl_iterator decls_begin() const
TypedefDecl * getObjCClassDecl() const
Retrieve the typedef declaration corresponding to the predefined Objective-C 'Class' type...
const LangOptions & LangOpts
Contains information about the compound statement currently being parsed.
bool EmitCurrentDiagnostic(bool Force=false)
Emit the current diagnostic and clear the diagnostic state.
void Emit(const DiagnosticBuilder &DB) const
static bool IsCallableWithAppend(Expr *E)
void setLastDiagnosticIgnored()
Pretend that the last diagnostic issued was ignored, so any subsequent notes will be suppressed...
Sema - This implements semantic analysis and AST building for C.
TentativeDefinitionsType TentativeDefinitions
All the tentative definitions encountered in the TU.
const llvm::MapVector< FieldDecl *, DeleteLocs > & getMismatchingDeleteExpressions() const
Retains information about a captured region.
unsigned getCurrentDiagID() const
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
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)
virtual void ReadMismatchingDeleteExpressions(llvm::MapVector< FieldDecl *, llvm::SmallVector< std::pair< SourceLocation, bool >, 4 >> &)
std::vector< bool > & Stack
QualType getAtomicType(QualType T) const
Return the uniqued reference to the atomic type for the specified type.
QualType getPointeeType() const
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...
CommentOptions CommentOpts
Options for parsing comments.
Retains information about a block that is currently being parsed.
bool isDeleted() const
Whether this function has been deleted.
An abstract interface that should be implemented by external AST sources that also provide informatio...
static bool ShouldRemoveFromUnused(Sema *SemaRef, const DeclaratorDecl *D)
Used to prune the decls of Sema's UnusedFileScopedDecls vector.
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 isBeforeInTranslationUnit(SourceLocation LHS, SourceLocation RHS) const
Determines the order of 2 source locations in the translation unit.
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
decls_iterator decls_end() const
friend_iterator friend_begin() const
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
void addImplicitTypedef(StringRef Name, QualType T)
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
Defines the clang::Preprocessor interface.
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
DeclContext * getDeclContext()
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
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...
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
llvm::DenseMap< NamedDecl *, SourceLocation > UndefinedButUsed
ASTMutationListener * getASTMutationListener() 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()
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isExternallyVisible() const
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
DeclarationName getDeclName() const
DiagnosticsEngine & getDiagnostics() const
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
sema::LambdaScopeInfo * PushLambdaScope()
unsigned NumSFINAEErrors
The number of SFINAE diagnostics that have been trapped.
const clang::PrintingPolicy & getPrintingPolicy() const
llvm::DenseMap< const CXXRecordDecl *, bool > RecordCompleteMap
An abstract interface that should be implemented by external AST sources that also provide informatio...
decls_iterator decls_begin() const
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
unsigned Bool
Whether we can use 'bool' rather than '_Bool', even if the language doesn't actually have 'bool' (bec...
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
void print(raw_ostream &OS, const SourceManager &SM) const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
ExternalASTSource * getExternalSource() const
Retrieve a pointer to the external AST source associated with this AST context, if any...
bool isValid() const
Return true if this is a valid SourceLocation object.
bool getSuppressAllDiagnostics() const
Represents a static or instance method of a struct/union/class.
void DiagnoseUseOfUnimplementedSelectors()
ASTConsumer & getASTConsumer() const
void addDecl(NamedDecl *D)
void SetArgToStringFn(ArgToStringFnTy Fn, void *Cookie)
void EmitCurrentDiagnostic(unsigned DiagID)
Cause the active diagnostic on the DiagosticsEngine to be emitted. This is closely coupled to the Sem...
This declaration is only a declaration.
The diagnostic should be suppressed entirely.
SourceLocation getBegin() const
bool isTypeDependent() const
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. all methods are defined or pure virtual and all friends, friend functions and nested classes are fully defined in this translation unit.
std::unique_ptr< CXXFieldCollector > FieldCollector
FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
TypedefDecl * getInt128Decl() const
Retrieve the declaration for the 128-bit signed integer type.
sema::FunctionScopeInfo * getCurFunction() const
sema::CapturedRegionScopeInfo * getCurCapturedRegion()
Retrieve the current captured region, if any.
static bool isBuiltinNote(unsigned DiagID)
Determine whether the given built-in diagnostic ID is a Note.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
DiagnosticsEngine & getDiagnostics() const
SourceLocation getExprLoc() const LLVM_READONLY
Base class for declarations which introduce a typedef-name.
Abstract interface for a consumer of code-completion information.
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
TypedefDecl * buildImplicitTypedef(QualType T, StringRef Name) const
Create a new implicit TU-level typedef declaration.
LateTemplateParserCleanupCB * LateTemplateParserCleanup
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
Converts an integral complex to bool by comparing against 0+0i.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
bool isInvalidDecl() const
void RecordParsingTemplateParameterDepth(unsigned Depth)
This is used to inform Sema what the current TemplateParameterDepth is during Parsing. Currently it is used to pass on the depth when parsing generic lambda 'auto' parameters.
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
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. Returns true if recovery was attempted or...
OverloadExpr * Expression
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
A set of unresolved declarations.
IdentifierResolver IdResolver
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
Abstract interface for a module loader.
NamedDecl * getCurFunctionOrMethodDecl()
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
Encapsulates the data about a macro definition (e.g. its tokens).
DeclarationName VAListTagName
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.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>. Pointer - pointer requires t...
SourceManager & getSourceManager() const
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
CanQualType UnsignedLongTy
FunctionDecl * getCurFunctionDecl()
void print(raw_ostream &OS) const override
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
void addComment(const RawComment &RC)
ImplicitParamDecl * getContextParam() const
Retrieve the parameter containing captured variables.
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.
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
SourceManager & getSourceManager()
void ActOnTranslationUnitScope(Scope *S)
virtual void Initialize(ASTContext &Context)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
void setSuppressAllDiagnostics(bool Val=true)
Suppress all diagnostics, to silence the front end when we know that we don't want any more diagnosti...
void * VisContext
VisContext - Manages the stack for #pragma GCC visibility.
virtual void ReadUndefinedButUsed(llvm::DenseMap< NamedDecl *, SourceLocation > &Undefined)
Load the set of used but not defined functions or variables with internal linkage, or used but not defined internal functions.
SmallVector< PossiblyUnreachableDiag, 4 > PossiblyUnreachableDiags
A list of PartialDiagnostics created but delayed within the current function scope. These diagnostics are vetted for reachability prior to being emitted.
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.
BoundNodesTreeBuilder *const Builder
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
OverloadsShown getShowOverloads() const
CanQualType OCLImage1dArrayTy
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...
bool tryExprAsCall(Expr &E, QualType &ZeroArgCallReturnTy, UnresolvedSetImpl &NonTemplateOverloads)
Figure out if an expression could be turned into a call.
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Defines the clang::TargetInfo interface.
The diagnostic should be reported.
bool makeUnavailableInSystemHeader(SourceLocation loc, StringRef message)
void PrintStats() const
Print out statistics about the semantic analysis.
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. [C99 6.5.1p2].
NamedDecl * getMostRecentDecl()
QualType getUIntPtrType() const
Return a type compatible with "uintptr_t" (C99 7.18.1.4), as defined by the target.
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
DeclContext * getPrimaryContext()
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...
SourceLocation getCurrentDiagLoc() const
TypedefDecl * getObjCSelDecl() const
Retrieve the typedef corresponding to the predefined 'SEL' type in Objective-C.
SmallVector< CompoundScopeInfo, 4 > CompoundScopes
The stack of currently active compound stamement scopes in the function.
virtual void CompleteTentativeDefinition(VarDecl *D)
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void PushCapturedRegionScope(Scope *RegionScope, CapturedDecl *CD, RecordDecl *RD, CapturedRegionKind K)
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
bool isConstQualified() const
Determine whether this type is const-qualified.
SmallVector< std::pair< const CXXMethodDecl *, const CXXMethodDecl * >, 2 > DelayedExceptionSpecChecks
All the overriding functions seen during a class definition that had their exception spec checks dela...
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
void setType(QualType newType)
Optional< NullabilityKind > getNullability(const ASTContext &context) const
static void checkUndefinedButUsed(Sema &S)
SmallVector< std::pair< CXXMethodDecl *, const FunctionProtoType * >, 2 > DelayedDefaultedMemberExceptionSpecs
All the members seen during a class definition which were both explicitly defaulted and had explicitl...
This class handles loading and caching of source files into memory.
Preprocessor & getPreprocessor() const
Declaration of a template function.
void PushFunctionScope()
Enter a new function scope.
NamedDeclSetType UnusedPrivateFields
Set containing all declared private fields that are not used.
ScalarTypeKind getScalarTypeKind() const
getScalarTypeKind - Given that this is a scalar type, classify it.
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
CanQualType UnsignedIntTy
The translation unit is a module.