15 #ifndef LLVM_CLANG_SEMA_SEMAINTERNAL_H 16 #define LLVM_CLANG_SEMA_SEMAINTERNAL_H 33 cast<ParmVarDecl>(FTI.
Params[0].
Param)->getType()->isVoidType();
46 return !isa<ParmVarDecl>(Var) &&
55 if (!LangOpts.CUDA || !D)
57 bool isDeviceSideDecl = D->
hasAttr<CUDADeviceAttr>() ||
60 return isDeviceSideDecl == LangOpts.CUDAIsDevice;
72 const unsigned *
const FunctionScopeIndexToStopAt) {
87 CaptureType, DeclRefType,
88 FunctionScopeIndexToStopAt);
95 assert(!(D->
hasAttr<DLLImportAttr>() && D->
hasAttr<DLLExportAttr>()) &&
96 "A declaration cannot be both dllimport and dllexport.");
97 if (
auto *Import = D->
getAttr<DLLImportAttr>())
99 if (
auto *Export = D->
getAttr<DLLExportAttr>())
106 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(ND))
107 return std::make_pair(TTP->getDepth(), TTP->getIndex());
109 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(ND))
110 return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
112 const auto *TTP = cast<TemplateTemplateParmDecl>(ND);
113 return std::make_pair(TTP->getDepth(), TTP->getIndex());
117 inline std::pair<unsigned, unsigned>
120 return std::make_pair(TTP->getDepth(), TTP->getIndex());
127 typedef llvm::StringMap<TypoResultList> TypoResultsMap;
128 typedef std::map<unsigned, TypoResultsMap> TypoEditDistanceMap;
135 std::unique_ptr<CorrectionCandidateCallback> CCC,
137 bool EnteringContext)
138 : Typo(TypoName.
getName().getAsIdentifierInfo()), CurrentTCIndex(0),
139 SavedTCIndex(0), SemaRef(SemaRef), S(S),
141 CorrectionValidator(
std::move(CCC)), MemberContext(MemberContext),
142 Result(SemaRef, TypoName, LookupKind),
144 EnteringContext(EnteringContext), SearchNamespaces(
false) {
145 Result.suppressDiagnostics();
154 bool InBaseClass)
override;
155 void FoundName(StringRef Name);
156 void addKeywordResult(StringRef Keyword);
160 return CorrectionResults.empty() && ValidatedCorrections.size() == 1;
166 return CorrectionResults.begin()->second[Name];
172 if (CorrectionResults.empty())
175 unsigned BestED = CorrectionResults.begin()->first;
184 addNamespaces(
const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces);
195 return CurrentTCIndex < ValidatedCorrections.size()
196 ? ValidatedCorrections[CurrentTCIndex]
197 : ValidatedCorrections[0];
205 auto Current = CurrentTCIndex;
207 CurrentTCIndex = Current;
221 return CorrectionResults.empty() &&
222 CurrentTCIndex >= ValidatedCorrections.size();
228 SavedTCIndex = CurrentTCIndex;
233 CurrentTCIndex = SavedTCIndex;
243 return CorrectionValidator.get();
247 class NamespaceSpecifierSet {
248 struct SpecifierInfo {
251 unsigned EditDistance;
258 DeclContextList CurContextChain;
259 std::string CurNameSpecifier;
263 std::map<unsigned, SpecifierInfoList> DistanceMap;
267 static DeclContextList buildContextChain(
DeclContext *Start);
269 unsigned buildNestedNameSpecifier(DeclContextList &DeclChain,
282 :
public llvm::iterator_facade_base<iterator, std::forward_iterator_tag,
285 const std::map<unsigned, SpecifierInfoList>::iterator OuterBack;
287 std::map<unsigned, SpecifierInfoList>::iterator Outer;
289 SpecifierInfoList::iterator Inner;
293 : OuterBack(
std::prev(Set.DistanceMap.end())),
294 Outer(Set.DistanceMap.begin()),
295 Inner(!IsAtEnd ? Outer->second.begin() : OuterBack->second.end()) {
296 assert(!Set.DistanceMap.empty());
301 if (Inner == Outer->second.end() && Outer != OuterBack) {
303 Inner = Outer->second.begin();
316 void addName(StringRef Name,
NamedDecl *ND,
328 void performQualifiedLookups();
338 TypoEditDistanceMap CorrectionResults;
341 size_t CurrentTCIndex;
346 std::unique_ptr<CXXScopeSpec> SS;
347 std::unique_ptr<CorrectionCandidateCallback> CorrectionValidator;
350 NamespaceSpecifierSet Namespaces;
352 bool EnteringContext;
353 bool SearchNamespaces;
356 inline Sema::TypoExprState::TypoExprState() {}
358 inline Sema::TypoExprState::TypoExprState(TypoExprState &&other) noexcept {
359 *
this = std::move(other);
362 inline Sema::TypoExprState &Sema::TypoExprState::
363 operator=(Sema::TypoExprState &&other) noexcept {
364 Consumer = std::move(other.Consumer);
365 DiagHandler = std::move(other.DiagHandler);
366 RecoveryHandler = std::move(other.RecoveryHandler);
Defines the clang::ASTContext interface.
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
Decl - This represents one declaration (or definition), e.g.
CorrectionCandidateCallback * getCorrectionValidator() const
const Expr * getAnyInitializer() const
Get the initializer for this variable, no matter which declaration it is attached to...
TypoResultList & operator[](StringRef Name)
Return the list of TypoCorrections for the given identifier from the set of corrections that have the...
void saveCurrentPosition()
Save the current position in the correction stream (overwriting any previously saved position)...
Consumes visible declarations found when searching for all visible names within a given scope or cont...
Represents a variable declaration or definition.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool finished()
Return whether the end of the stream of corrections has been reached.
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
std::string getName(ArrayRef< StringRef > Parts) const
Get the platform-specific name separator.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
One of these records is kept for each identifier that is lexed.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Represents the results of name lookup.
bool FTIHasSingleVoidParameter(const DeclaratorChunk::FunctionTypeInfo &FTI)
Scope - A scope is a transient data structure that is used while parsing the program.
static unsigned NormalizeEditDistance(unsigned ED)
Represents a C++ nested-name-specifier or a global scope specifier.
const LangOptions & LangOpts
ASTContext & getContext() const
Sema - This implements semantic analysis and AST building for C.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
std::pair< unsigned, unsigned > getDepthAndIndex(NamedDecl *ND)
Retrieve the depth and index of a template parameter.
void restoreSavedPosition()
Restore the saved position in the correction stream.
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
LookupNameKind
Describes the kind of name lookup to perform.
const CXXScopeSpec * getSS() const
bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context)
DefinitionKind hasDefinition(ASTContext &) const
Check whether this variable is defined in this translation unit.
PartialDiagnostic::StorageAllocator & getDiagAllocator()
The result type of a method or function.
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
TypoCorrectionConsumer(Sema &SemaRef, const DeclarationNameInfo &TypoName, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, DeclContext *MemberContext, bool EnteringContext)
bool isAddressOfOperand() const
Encodes a location in the source.
SpecifierInfo & operator*()
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool isExternalWithNoLinkageType(ValueDecl *VD)
Determine if VD, which must be a variable or function, is an external symbol that nonetheless can't b...
const LookupResult & getLookupResult() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
This declaration is only a declaration.
bool operator==(const iterator &RHS) const
Dataflow Directional Tag Classes.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
unsigned isVariadic
isVariadic - If this function has a prototype, and if that proto ends with ',...)', this is true.
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
const TypoCorrection & peekNextCorrection()
Return the next typo correction like getNextCorrection, but keep the internal state pointed to the cu...
iterator(NamespaceSpecifierSet &Set, bool IsAtEnd)
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
Provides flat iteration over specifiers, sorted by distance.
bool includeHiddenDecls() const override
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
const TypoCorrection & getCurrentCorrection()
Get the last correction returned by getNextCorrection().
__DEVICE__ int max(int __a, int __b)
unsigned getBestEditDistance(bool Normalized)
Return the edit distance of the corrections that have the closest/best edit distance from the origina...
bool isStaticDataMember() const
Determines whether this is a static data member.
void resetCorrectionStream()
Reset the consumer's position in the stream of viable corrections (i.e.
This represents a decl that may have a name.
bool isInline() const
Whether this variable is (C++1z) inline.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
bool isExternallyVisible() const