14 #ifndef LLVM_CLANG_SEMA_SEMAINTERNAL_H 15 #define LLVM_CLANG_SEMA_SEMAINTERNAL_H 32 cast<ParmVarDecl>(FTI.
Params[0].
Param)->getType()->isVoidType();
45 if (!LangOpts.CUDA || !D)
47 bool isDeviceSideDecl = D->
hasAttr<CUDADeviceAttr>() ||
50 return isDeviceSideDecl == LangOpts.CUDAIsDevice;
55 assert(!(D->
hasAttr<DLLImportAttr>() && D->
hasAttr<DLLExportAttr>()) &&
56 "A declaration cannot be both dllimport and dllexport.");
57 if (
auto *Import = D->
getAttr<DLLImportAttr>())
59 if (
auto *Export = D->
getAttr<DLLExportAttr>())
66 if (
const auto *TTP = dyn_cast<TemplateTypeParmDecl>(ND))
67 return std::make_pair(TTP->getDepth(), TTP->getIndex());
69 if (
const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(ND))
70 return std::make_pair(NTTP->getDepth(), NTTP->getIndex());
72 const auto *TTP = cast<TemplateTemplateParmDecl>(ND);
73 return std::make_pair(TTP->getDepth(), TTP->getIndex());
77 inline std::pair<unsigned, unsigned>
80 return std::make_pair(TTP->getDepth(), TTP->getIndex());
87 typedef llvm::StringMap<TypoResultList> TypoResultsMap;
88 typedef std::map<unsigned, TypoResultsMap> TypoEditDistanceMap;
95 std::unique_ptr<CorrectionCandidateCallback> CCC,
98 : Typo(TypoName.
getName().getAsIdentifierInfo()), CurrentTCIndex(0),
99 SavedTCIndex(0), SemaRef(SemaRef), S(S),
101 CorrectionValidator(
std::move(CCC)), MemberContext(MemberContext),
102 Result(SemaRef, TypoName, LookupKind),
104 EnteringContext(EnteringContext), SearchNamespaces(
false) {
105 Result.suppressDiagnostics();
114 bool InBaseClass)
override;
115 void FoundName(StringRef Name);
116 void addKeywordResult(StringRef Keyword);
120 return CorrectionResults.empty() && ValidatedCorrections.size() == 1;
126 return CorrectionResults.begin()->second[Name];
132 if (CorrectionResults.empty())
135 unsigned BestED = CorrectionResults.begin()->first;
144 addNamespaces(
const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces);
155 return CurrentTCIndex < ValidatedCorrections.size()
156 ? ValidatedCorrections[CurrentTCIndex]
157 : ValidatedCorrections[0];
165 auto Current = CurrentTCIndex;
167 CurrentTCIndex = Current;
181 return CorrectionResults.empty() &&
182 CurrentTCIndex >= ValidatedCorrections.size();
188 SavedTCIndex = CurrentTCIndex;
193 CurrentTCIndex = SavedTCIndex;
203 return CorrectionValidator.get();
207 class NamespaceSpecifierSet {
208 struct SpecifierInfo {
211 unsigned EditDistance;
218 DeclContextList CurContextChain;
219 std::string CurNameSpecifier;
223 std::map<unsigned, SpecifierInfoList> DistanceMap;
227 static DeclContextList buildContextChain(
DeclContext *Start);
229 unsigned buildNestedNameSpecifier(DeclContextList &DeclChain,
242 :
public llvm::iterator_facade_base<iterator, std::forward_iterator_tag,
245 const std::map<unsigned, SpecifierInfoList>::iterator OuterBack;
247 std::map<unsigned, SpecifierInfoList>::iterator Outer;
249 SpecifierInfoList::iterator Inner;
253 : OuterBack(
std::prev(Set.DistanceMap.end())),
254 Outer(Set.DistanceMap.begin()),
255 Inner(!IsAtEnd ? Outer->second.begin() : OuterBack->second.end()) {
256 assert(!Set.DistanceMap.empty());
261 if (Inner == Outer->second.end() && Outer != OuterBack) {
263 Inner = Outer->second.begin();
276 void addName(StringRef Name,
NamedDecl *ND,
288 void performQualifiedLookups();
298 TypoEditDistanceMap CorrectionResults;
301 size_t CurrentTCIndex;
306 std::unique_ptr<CXXScopeSpec> SS;
307 std::unique_ptr<CorrectionCandidateCallback> CorrectionValidator;
310 NamespaceSpecifierSet Namespaces;
312 bool EnteringContext;
313 bool SearchNamespaces;
316 inline Sema::TypoExprState::TypoExprState() {}
318 inline Sema::TypoExprState::TypoExprState(TypoExprState &&other) noexcept {
319 *
this = std::move(other);
322 inline Sema::TypoExprState &Sema::TypoExprState::
323 operator=(Sema::TypoExprState &&other) noexcept {
324 Consumer = std::move(other.Consumer);
325 DiagHandler = std::move(other.DiagHandler);
326 RecoveryHandler = std::move(other.RecoveryHandler);
Defines the clang::ASTContext interface.
std::pair< llvm::PointerUnion< const TemplateTypeParmType *, NamedDecl * >, SourceLocation > UnexpandedParameterPack
Simple class containing the result of Sema::CorrectTypo.
Decl - This represents one declaration (or definition), e.g.
CorrectionCandidateCallback * getCorrectionValidator() const
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...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
bool finished()
Return whether the end of the stream of corrections has been reached.
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...
__DEVICE__ int max(int __a, int __b)
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.
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
PartialDiagnostic::StorageAllocator & getDiagAllocator()
The result type of a method or function.
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
SpecifierInfo & operator*()
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
const LookupResult & getLookupResult() const
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
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...
static std::string getName(const CallEvent &Call)
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)
const TypoCorrection & peekNextCorrection()
Return the next typo correction like getNextCorrection, but keep the internal state pointed to the cu...
iterator(NamespaceSpecifierSet &Set, bool IsAtEnd)
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...
void resetCorrectionStream()
Reset the consumer's position in the stream of viable corrections (i.e.
This represents a decl that may have a name.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...