#include "clang/AST/ASTContext.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclLookups.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FileManager.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/DeclSpec.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Overload.h"
#include "clang/Sema/RISCVIntrinsicManager.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaRISCV.h"
#include "clang/Sema/TemplateDeduction.h"
#include "clang/Sema/TypoCorrection.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/TinyPtrVector.h"
#include "llvm/ADT/edit_distance.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/ErrorHandling.h"
#include <algorithm>
#include <iterator>
#include <list>
#include <optional>
#include <set>
#include <utility>
#include <vector>
#include "OpenCLBuiltins.inc"
usingnamespaceclang;
usingnamespacesema;
namespace {
class UnqualUsingEntry { … };
class UnqualUsingDirectiveSet { … };
}
static inline unsigned getIDNS(Sema::LookupNameKind NameKind,
bool CPlusPlus,
bool Redeclaration) { … }
void LookupResult::configure() { … }
bool LookupResult::checkDebugAssumptions() const { … }
void LookupResult::deletePaths(CXXBasePaths *Paths) { … }
static const DeclContext *getContextForScopeMatching(const Decl *D) { … }
static bool isPreferredLookupResult(Sema &S, Sema::LookupNameKind Kind,
const NamedDecl *D,
const NamedDecl *Existing) { … }
static bool canHideTag(const NamedDecl *D) { … }
void LookupResult::resolveKind() { … }
void LookupResult::addDeclsFromBasePaths(const CXXBasePaths &P) { … }
void LookupResult::setAmbiguousBaseSubobjects(CXXBasePaths &P) { … }
void LookupResult::setAmbiguousBaseSubobjectTypes(CXXBasePaths &P) { … }
void LookupResult::print(raw_ostream &Out) { … }
LLVM_DUMP_METHOD void LookupResult::dump() { … }
static QualType diagOpenCLBuiltinTypeError(Sema &S, llvm::StringRef TypeClass,
llvm::StringRef Name) { … }
static QualType getOpenCLEnumType(Sema &S, llvm::StringRef Name) { … }
static QualType getOpenCLTypedefType(Sema &S, llvm::StringRef Name) { … }
static void GetQualTypesForOpenCLBuiltin(
Sema &S, const OpenCLBuiltinStruct &OpenCLBuiltin, unsigned &GenTypeMaxCnt,
SmallVector<QualType, 1> &RetTypes,
SmallVector<SmallVector<QualType, 1>, 5> &ArgTypes) { … }
static void GetOpenCLBuiltinFctOverloads(
ASTContext &Context, unsigned GenTypeMaxCnt,
std::vector<QualType> &FunctionList, SmallVector<QualType, 1> &RetTypes,
SmallVector<SmallVector<QualType, 1>, 5> &ArgTypes) { … }
static void InsertOCLBuiltinDeclarationsFromTable(Sema &S, LookupResult &LR,
IdentifierInfo *II,
const unsigned FctIndex,
const unsigned Len) { … }
bool Sema::LookupBuiltin(LookupResult &R) { … }
static void LookupPredefedObjCSuperType(Sema &Sema, Scope *S) { … }
void Sema::LookupNecessaryTypesForBuiltin(Scope *S, unsigned ID) { … }
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class) { … }
void Sema::ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class) { … }
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name) { … }
static void DeclareImplicitMemberFunctionsWithName(Sema &S,
DeclarationName Name,
SourceLocation Loc,
const DeclContext *DC) { … }
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC) { … }
static bool CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context,
const DeclContext *NS,
UnqualUsingDirectiveSet &UDirs) { … }
static bool isNamespaceOrTranslationUnitScope(Scope *S) { … }
static DeclContext *findOuterContext(Scope *S) { … }
namespace {
struct FindLocalExternScope { … };
}
bool Sema::CppLookupName(LookupResult &R, Scope *S) { … }
void Sema::makeMergedDefinitionVisible(NamedDecl *ND) { … }
static Module *getDefiningModule(Sema &S, Decl *Entity) { … }
llvm::DenseSet<Module*> &Sema::getLookupModules() { … }
bool Sema::isUsableModule(const Module *M) { … }
bool Sema::hasVisibleMergedDefinition(const NamedDecl *Def) { … }
bool Sema::hasMergedDefinitionInCurrentModule(const NamedDecl *Def) { … }
template <typename ParmDecl>
static bool
hasAcceptableDefaultArgument(Sema &S, const ParmDecl *D,
llvm::SmallVectorImpl<Module *> *Modules,
Sema::AcceptableKind Kind) { … }
bool Sema::hasAcceptableDefaultArgument(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules,
Sema::AcceptableKind Kind) { … }
bool Sema::hasVisibleDefaultArgument(const NamedDecl *D,
llvm::SmallVectorImpl<Module *> *Modules) { … }
bool Sema::hasReachableDefaultArgument(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
template <typename Filter>
static bool
hasAcceptableDeclarationImpl(Sema &S, const NamedDecl *D,
llvm::SmallVectorImpl<Module *> *Modules, Filter F,
Sema::AcceptableKind Kind) { … }
static bool
hasAcceptableExplicitSpecialization(Sema &S, const NamedDecl *D,
llvm::SmallVectorImpl<Module *> *Modules,
Sema::AcceptableKind Kind) { … }
bool Sema::hasVisibleExplicitSpecialization(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
bool Sema::hasReachableExplicitSpecialization(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
static bool
hasAcceptableMemberSpecialization(Sema &S, const NamedDecl *D,
llvm::SmallVectorImpl<Module *> *Modules,
Sema::AcceptableKind Kind) { … }
bool Sema::hasVisibleMemberSpecialization(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
bool Sema::hasReachableMemberSpecialization(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
bool LookupResult::isAcceptableSlow(Sema &SemaRef, NamedDecl *D,
Sema::AcceptableKind Kind) { … }
bool Sema::isModuleVisible(const Module *M, bool ModulePrivate) { … }
bool LookupResult::isReachableSlow(Sema &SemaRef, NamedDecl *D) { … }
bool Sema::isAcceptableSlow(const NamedDecl *D, Sema::AcceptableKind Kind) { … }
bool Sema::shouldLinkPossiblyHiddenDecl(LookupResult &R, const NamedDecl *New) { … }
static NamedDecl *findAcceptableDecl(Sema &SemaRef, NamedDecl *D,
unsigned IDNS) { … }
bool Sema::hasVisibleDeclarationSlow(const NamedDecl *D,
llvm::SmallVectorImpl<Module *> *Modules) { … }
bool Sema::hasReachableDeclarationSlow(
const NamedDecl *D, llvm::SmallVectorImpl<Module *> *Modules) { … }
NamedDecl *LookupResult::getAcceptableDeclSlow(NamedDecl *D) const { … }
bool LookupResult::isVisible(Sema &SemaRef, NamedDecl *D) { … }
bool LookupResult::isReachable(Sema &SemaRef, NamedDecl *D) { … }
bool LookupResult::isAvailableForLookup(Sema &SemaRef, NamedDecl *ND) { … }
bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation,
bool ForceNoCPlusPlus) { … }
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R,
DeclContext *StartDC) { … }
bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
bool InUnqualifiedLookup) { … }
bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
CXXScopeSpec &SS) { … }
bool Sema::LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS,
QualType ObjectType, bool AllowBuiltinCreation,
bool EnteringContext) { … }
bool Sema::LookupInSuper(LookupResult &R, CXXRecordDecl *Class) { … }
void Sema::DiagnoseAmbiguousLookup(LookupResult &Result) { … }
namespace {
struct AssociatedLookup { … };
}
static void
addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T);
static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces,
DeclContext *Ctx) { … }
static void
addAssociatedClassesAndNamespaces(AssociatedLookup &Result,
const TemplateArgument &Arg) { … }
static void
addAssociatedClassesAndNamespaces(AssociatedLookup &Result,
CXXRecordDecl *Class) { … }
static void
addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType Ty) { … }
void Sema::FindAssociatedClassesAndNamespaces(
SourceLocation InstantiationLoc, ArrayRef<Expr *> Args,
AssociatedNamespaceSet &AssociatedNamespaces,
AssociatedClassSet &AssociatedClasses) { … }
NamedDecl *Sema::LookupSingleName(Scope *S, DeclarationName Name,
SourceLocation Loc,
LookupNameKind NameKind,
RedeclarationKind Redecl) { … }
void Sema::LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S,
UnresolvedSetImpl &Functions) { … }
Sema::SpecialMemberOverloadResult
Sema::LookupSpecialMember(CXXRecordDecl *RD, CXXSpecialMemberKind SM,
bool ConstArg, bool VolatileArg, bool RValueThis,
bool ConstThis, bool VolatileThis) { … }
CXXConstructorDecl *Sema::LookupDefaultConstructor(CXXRecordDecl *Class) { … }
CXXConstructorDecl *Sema::LookupCopyingConstructor(CXXRecordDecl *Class,
unsigned Quals) { … }
CXXConstructorDecl *Sema::LookupMovingConstructor(CXXRecordDecl *Class,
unsigned Quals) { … }
DeclContext::lookup_result Sema::LookupConstructors(CXXRecordDecl *Class) { … }
CXXMethodDecl *Sema::LookupCopyingAssignment(CXXRecordDecl *Class,
unsigned Quals, bool RValueThis,
unsigned ThisQuals) { … }
CXXMethodDecl *Sema::LookupMovingAssignment(CXXRecordDecl *Class,
unsigned Quals,
bool RValueThis,
unsigned ThisQuals) { … }
CXXDestructorDecl *Sema::LookupDestructor(CXXRecordDecl *Class) { … }
Sema::LiteralOperatorLookupResult
Sema::LookupLiteralOperator(Scope *S, LookupResult &R,
ArrayRef<QualType> ArgTys, bool AllowRaw,
bool AllowTemplate, bool AllowStringTemplatePack,
bool DiagnoseMissing, StringLiteral *StringLit) { … }
void ADLResult::insert(NamedDecl *New) { … }
void Sema::ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc,
ArrayRef<Expr *> Args, ADLResult &Result) { … }
VisibleDeclConsumer::~VisibleDeclConsumer() { … }
bool VisibleDeclConsumer::includeHiddenDecls() const { … }
namespace {
class ShadowContextRAII;
class VisibleDeclsRecord { … };
class ShadowContextRAII { … };
}
NamedDecl *VisibleDeclsRecord::checkHidden(NamedDecl *ND) { … }
namespace {
class LookupVisibleHelper { … };
}
void Sema::LookupVisibleDecls(Scope *S, LookupNameKind Kind,
VisibleDeclConsumer &Consumer,
bool IncludeGlobalScope, bool LoadExternal) { … }
void Sema::LookupVisibleDecls(DeclContext *Ctx, LookupNameKind Kind,
VisibleDeclConsumer &Consumer,
bool IncludeGlobalScope,
bool IncludeDependentBases, bool LoadExternal) { … }
LabelDecl *Sema::LookupOrCreateLabel(IdentifierInfo *II, SourceLocation Loc,
SourceLocation GnuLabelLoc) { … }
static bool isCandidateViable(CorrectionCandidateCallback &CCC,
TypoCorrection &Candidate) { … }
static void LookupPotentialTypoResult(Sema &SemaRef,
LookupResult &Res,
IdentifierInfo *Name,
Scope *S, CXXScopeSpec *SS,
DeclContext *MemberContext,
bool EnteringContext,
bool isObjCIvarLookup,
bool FindHidden);
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC) { … }
static void getNestedNameSpecifierIdentifiers(
NestedNameSpecifier *NNS,
SmallVectorImpl<const IdentifierInfo*> &Identifiers) { … }
void TypoCorrectionConsumer::FoundDecl(NamedDecl *ND, NamedDecl *Hiding,
DeclContext *Ctx, bool InBaseClass) { … }
void TypoCorrectionConsumer::FoundName(StringRef Name) { … }
void TypoCorrectionConsumer::addKeywordResult(StringRef Keyword) { … }
void TypoCorrectionConsumer::addName(StringRef Name, NamedDecl *ND,
NestedNameSpecifier *NNS, bool isKeyword) { … }
static const unsigned MaxTypoDistanceResultSets = …;
void TypoCorrectionConsumer::addCorrection(TypoCorrection Correction) { … }
void TypoCorrectionConsumer::addNamespaces(
const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) { … }
const TypoCorrection &TypoCorrectionConsumer::getNextCorrection() { … }
bool TypoCorrectionConsumer::resolveCorrection(TypoCorrection &Candidate) { … }
void TypoCorrectionConsumer::performQualifiedLookups() { … }
TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
ASTContext &Context, DeclContext *CurContext, CXXScopeSpec *CurScopeSpec)
: … { … }
auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
DeclContext *Start) -> DeclContextList { … }
unsigned
TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
DeclContextList &DeclChain, NestedNameSpecifier *&NNS) { … }
void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
DeclContext *Ctx) { … }
static void LookupPotentialTypoResult(Sema &SemaRef,
LookupResult &Res,
IdentifierInfo *Name,
Scope *S, CXXScopeSpec *SS,
DeclContext *MemberContext,
bool EnteringContext,
bool isObjCIvarLookup,
bool FindHidden) { … }
static void AddKeywordsToConsumer(Sema &SemaRef,
TypoCorrectionConsumer &Consumer,
Scope *S, CorrectionCandidateCallback &CCC,
bool AfterNestedNameSpecifier) { … }
std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
const DeclarationNameInfo &TypoName, Sema::LookupNameKind LookupKind,
Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC,
DeclContext *MemberContext, bool EnteringContext,
const ObjCObjectPointerType *OPT, bool ErrorRecovery) { … }
TypoCorrection Sema::CorrectTypo(const DeclarationNameInfo &TypoName,
Sema::LookupNameKind LookupKind,
Scope *S, CXXScopeSpec *SS,
CorrectionCandidateCallback &CCC,
CorrectTypoKind Mode,
DeclContext *MemberContext,
bool EnteringContext,
const ObjCObjectPointerType *OPT,
bool RecordFailure) { … }
TypoExpr *Sema::CorrectTypoDelayed(
const DeclarationNameInfo &TypoName, Sema::LookupNameKind LookupKind,
Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC,
TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode,
DeclContext *MemberContext, bool EnteringContext,
const ObjCObjectPointerType *OPT) { … }
void TypoCorrection::addCorrectionDecl(NamedDecl *CDecl) { … }
std::string TypoCorrection::getAsString(const LangOptions &LO) const { … }
bool CorrectionCandidateCallback::ValidateCandidate(
const TypoCorrection &candidate) { … }
FunctionCallFilterCCC::FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs,
bool HasExplicitTemplateArgs,
MemberExpr *ME)
: … { … }
bool FunctionCallFilterCCC::ValidateCandidate(const TypoCorrection &candidate) { … }
void Sema::diagnoseTypo(const TypoCorrection &Correction,
const PartialDiagnostic &TypoDiag,
bool ErrorRecovery) { … }
static const NamedDecl *getDefinitionToImport(const NamedDecl *D) { … }
void Sema::diagnoseMissingImport(SourceLocation Loc, const NamedDecl *Decl,
MissingImportKind MIK, bool Recover) { … }
static std::string getHeaderNameForHeader(Preprocessor &PP, FileEntryRef E,
llvm::StringRef IncludingFile) { … }
void Sema::diagnoseMissingImport(SourceLocation UseLoc, const NamedDecl *Decl,
SourceLocation DeclLoc,
ArrayRef<Module *> Modules,
MissingImportKind MIK, bool Recover) { … }
void Sema::diagnoseTypo(const TypoCorrection &Correction,
const PartialDiagnostic &TypoDiag,
const PartialDiagnostic &PrevNote,
bool ErrorRecovery) { … }
TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
TypoDiagnosticGenerator TDG,
TypoRecoveryCallback TRC,
SourceLocation TypoLoc) { … }
const Sema::TypoExprState &Sema::getTypoExprState(TypoExpr *TE) const { … }
void Sema::clearDelayedTypo(TypoExpr *TE) { … }
void Sema::ActOnPragmaDump(Scope *S, SourceLocation IILoc, IdentifierInfo *II) { … }
void Sema::ActOnPragmaDump(Expr *E) { … }
RedeclarationKind Sema::forRedeclarationInCurContext() const { … }