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 typedef llvm::StringMap<TypoResultList> TypoResultsMap;
107 typedef std::map<unsigned, TypoResultsMap> TypoEditDistanceMap;
114 std::unique_ptr<CorrectionCandidateCallback> CCC,
116 bool EnteringContext)
117 : Typo(TypoName.getName().getAsIdentifierInfo()), CurrentTCIndex(0),
118 SavedTCIndex(0), SemaRef(SemaRef), S(S),
120 CorrectionValidator(
std::move(CCC)), MemberContext(MemberContext),
121 Result(SemaRef, TypoName, LookupKind),
123 EnteringContext(EnteringContext), SearchNamespaces(
false) {
124 Result.suppressDiagnostics();
133 bool InBaseClass)
override;
134 void FoundName(StringRef Name);
135 void addKeywordResult(StringRef Keyword);
139 return CorrectionResults.empty() && ValidatedCorrections.size() == 1;
145 return CorrectionResults.begin()->second[Name];
151 if (CorrectionResults.empty())
154 unsigned BestED = CorrectionResults.begin()->first;
163 addNamespaces(
const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces);
174 return CurrentTCIndex < ValidatedCorrections.size()
175 ? ValidatedCorrections[CurrentTCIndex]
176 : ValidatedCorrections[0];
184 auto Current = CurrentTCIndex;
186 CurrentTCIndex = Current;
200 return CorrectionResults.empty() &&
201 CurrentTCIndex >= ValidatedCorrections.size();
207 SavedTCIndex = CurrentTCIndex;
212 CurrentTCIndex = SavedTCIndex;
222 return CorrectionValidator.get();
226 class NamespaceSpecifierSet {
227 struct SpecifierInfo {
230 unsigned EditDistance;
237 DeclContextList CurContextChain;
238 std::string CurNameSpecifier;
242 std::map<unsigned, SpecifierInfoList> DistanceMap;
246 static DeclContextList buildContextChain(
DeclContext *Start);
248 unsigned buildNestedNameSpecifier(DeclContextList &DeclChain,
261 :
public llvm::iterator_facade_base<iterator, std::forward_iterator_tag,
264 const std::map<unsigned, SpecifierInfoList>::iterator OuterBack;
266 std::map<unsigned, SpecifierInfoList>::iterator Outer;
268 SpecifierInfoList::iterator Inner;
272 : OuterBack(
std::prev(Set.DistanceMap.end())),
273 Outer(Set.DistanceMap.begin()),
274 Inner(!IsAtEnd ? Outer->second.begin() : OuterBack->second.end()) {
275 assert(!Set.DistanceMap.empty());
280 if (Inner == Outer->second.end() && Outer != OuterBack) {
282 Inner = Outer->second.begin();
295 void addName(StringRef Name,
NamedDecl *ND,
307 void performQualifiedLookups();
317 TypoEditDistanceMap CorrectionResults;
320 size_t CurrentTCIndex;
325 std::unique_ptr<CXXScopeSpec> SS;
326 std::unique_ptr<CorrectionCandidateCallback> CorrectionValidator;
329 NamespaceSpecifierSet Namespaces;
331 bool EnteringContext;
332 bool SearchNamespaces;
335 inline Sema::TypoExprState::TypoExprState() {}
337 inline Sema::TypoExprState::TypoExprState(TypoExprState &&other) noexcept {
338 *
this = std::move(other);
341 inline Sema::TypoExprState &Sema::TypoExprState::
342 operator=(Sema::TypoExprState &&other) noexcept {
343 Consumer = std::move(other.Consumer);
344 DiagHandler = std::move(other.DiagHandler);
345 RecoveryHandler = std::move(other.RecoveryHandler);
Defines the clang::ASTContext interface.
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
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
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
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...
VarDecl - An instance of this class is created to represent 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.
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...
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)
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
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().
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.
NamedDecl - This represents a decl with 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