39 #include "llvm/ADT/STLExtras.h"
40 #include "llvm/ADT/SetVector.h"
41 #include "llvm/ADT/SmallPtrSet.h"
42 #include "llvm/ADT/StringMap.h"
43 #include "llvm/ADT/TinyPtrVector.h"
44 #include "llvm/ADT/edit_distance.h"
45 #include "llvm/Support/ErrorHandling.h"
55 using namespace clang;
59 class UnqualUsingEntry {
66 : Nominated(Nominated), CommonAncestor(CommonAncestor) {
70 return CommonAncestor;
79 bool operator()(
const UnqualUsingEntry &L,
const UnqualUsingEntry &R) {
80 return L.getCommonAncestor() < R.getCommonAncestor();
83 bool operator()(
const UnqualUsingEntry &
E,
const DeclContext *DC) {
84 return E.getCommonAncestor() < DC;
87 bool operator()(
const DeclContext *DC,
const UnqualUsingEntry &E) {
88 return DC < E.getCommonAncestor();
95 class UnqualUsingDirectiveSet {
99 llvm::SmallPtrSet<DeclContext*, 8> visited;
102 UnqualUsingDirectiveSet() {}
104 void visitScopeChain(
Scope *
S,
Scope *InnermostFileScope) {
121 visit(
I, InnermostFileDC);
134 if (!visited.insert(DC).second)
137 addUsingDirectives(DC, EffectiveDC);
145 if (!visited.insert(NS).second)
148 addUsingDirective(UD, EffectiveDC);
149 addUsingDirectives(NS, EffectiveDC);
160 if (visited.insert(NS).second) {
161 addUsingDirective(UD, EffectiveDC);
169 DC = queue.pop_back_val();
184 while (!Common->
Encloses(EffectiveDC))
192 std::sort(list.begin(), list.end(), UnqualUsingEntry::Comparator());
195 typedef ListTy::const_iterator const_iterator;
197 const_iterator
begin()
const {
return list.begin(); }
198 const_iterator
end()
const {
return list.end(); }
200 llvm::iterator_range<const_iterator>
202 return llvm::make_range(std::equal_range(
begin(),
end(),
204 UnqualUsingEntry::Comparator()));
213 bool Redeclaration) {
220 IDNS = Decl::IDNS_Ordinary;
222 IDNS |= Decl::IDNS_Tag | Decl::IDNS_Member | Decl::IDNS_Namespace;
224 IDNS |= Decl::IDNS_TagFriend | Decl::IDNS_OrdinaryFriend;
227 IDNS |= Decl::IDNS_LocalExtern;
233 assert(!Redeclaration &&
"cannot do redeclaration operator lookup");
234 IDNS = Decl::IDNS_NonMemberOperator;
239 IDNS = Decl::IDNS_Type;
247 IDNS |= Decl::IDNS_Tag | Decl::IDNS_TagFriend | Decl::IDNS_Namespace;
249 IDNS = Decl::IDNS_Tag;
254 IDNS = Decl::IDNS_Label;
258 IDNS = Decl::IDNS_Member;
260 IDNS |= Decl::IDNS_Tag | Decl::IDNS_Ordinary;
264 IDNS = Decl::IDNS_Type | Decl::IDNS_Namespace;
268 IDNS = Decl::IDNS_Namespace;
272 assert(Redeclaration &&
"should only be used for redecl lookup");
273 IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Member |
274 Decl::IDNS_Using | Decl::IDNS_TagFriend | Decl::IDNS_OrdinaryFriend |
275 Decl::IDNS_LocalExtern;
279 IDNS = Decl::IDNS_ObjCProtocol;
283 IDNS = Decl::IDNS_OMPReduction;
287 IDNS = Decl::IDNS_Ordinary | Decl::IDNS_Tag | Decl::IDNS_Member
288 | Decl::IDNS_Using | Decl::IDNS_Namespace | Decl::IDNS_ObjCProtocol
295 void LookupResult::configure() {
297 isForRedeclaration());
302 switch (NameInfo.getName().getCXXOverloadedOperator()) {
306 case OO_Array_Delete:
307 getSema().DeclareGlobalNewDelete();
317 if (
unsigned BuiltinID = Id->getBuiltinID()) {
318 if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
324 bool LookupResult::sanity()
const {
326 assert(ResultKind != NotFound || Decls.size() == 0);
327 assert(ResultKind != Found || Decls.size() == 1);
328 assert(ResultKind != FoundOverloaded || Decls.size() > 1 ||
329 (Decls.size() == 1 &&
330 isa<FunctionTemplateDecl>((*
begin())->getUnderlyingDecl())));
331 assert(ResultKind != FoundUnresolvedValue || sanityCheckUnresolved());
332 assert(ResultKind != Ambiguous || Decls.size() > 1 ||
333 (Decls.size() == 1 && (Ambiguity == AmbiguousBaseSubobjects ||
334 Ambiguity == AmbiguousBaseSubobjectTypes)));
335 assert((Paths !=
nullptr) == (ResultKind == Ambiguous &&
336 (Ambiguity == AmbiguousBaseSubobjectTypes ||
337 Ambiguity == AmbiguousBaseSubobjects)));
358 return D->getDeclContext()->getRedeclContext();
368 !isa<UsingShadowDecl>(Existing))
380 if (DUnderlying->getCanonicalDecl() != EUnderlying->getCanonicalDecl()) {
381 assert(isa<TypeDecl>(DUnderlying) && isa<TypeDecl>(EUnderlying));
382 bool HaveTag = isa<TagDecl>(EUnderlying);
384 return HaveTag != WantTag;
391 if (
auto *DFD = dyn_cast<FunctionDecl>(DUnderlying)) {
392 auto *EFD = cast<FunctionDecl>(EUnderlying);
393 unsigned DMin = DFD->getMinRequiredArguments();
394 unsigned EMin = EFD->getMinRequiredArguments();
403 if (
auto *DTD = dyn_cast<TemplateDecl>(DUnderlying)) {
404 auto *ETD = cast<TemplateDecl>(EUnderlying);
405 unsigned DMin = DTD->getTemplateParameters()->getMinRequiredArguments();
406 unsigned EMin = ETD->getTemplateParameters()->getMinRequiredArguments();
415 for (
unsigned I = DMin, N = DTD->getTemplateParameters()->size();
418 ETD->getTemplateParameters()->getParam(
I)) &&
420 DTD->getTemplateParameters()->getParam(
I)))
427 if (
VarDecl *DVD = dyn_cast<VarDecl>(DUnderlying)) {
428 VarDecl *EVD = cast<VarDecl>(EUnderlying);
430 !DVD->getType()->isIncompleteType()) {
438 if (!isa<FunctionDecl>(DUnderlying) && !isa<VarDecl>(DUnderlying)) {
445 for (
Decl *Prev = DUnderlying->getPreviousDecl(); Prev;
446 Prev = Prev->getPreviousDecl())
447 if (Prev == EUnderlying)
465 return isa<VarDecl>(D) || isa<EnumConstantDecl>(D) || isa<FunctionDecl>(D) ||
466 isa<FunctionTemplateDecl>(D) || isa<FieldDecl>(D);
471 unsigned N = Decls.size();
475 assert(ResultKind == NotFound ||
476 ResultKind == NotFoundInCurrentInstantiation);
483 NamedDecl *D = (*Decls.begin())->getUnderlyingDecl();
484 if (isa<FunctionTemplateDecl>(D))
485 ResultKind = FoundOverloaded;
486 else if (isa<UnresolvedUsingValueDecl>(D))
487 ResultKind = FoundUnresolvedValue;
492 if (ResultKind == Ambiguous)
return;
494 llvm::SmallDenseMap<NamedDecl*, unsigned, 16> Unique;
495 llvm::SmallDenseMap<QualType, unsigned, 16> UniqueTypes;
497 bool Ambiguous =
false;
498 bool HasTag =
false, HasFunction =
false;
499 bool HasFunctionTemplate =
false, HasUnresolved =
false;
504 unsigned UniqueTagIndex = 0;
509 D = cast<NamedDecl>(D->getCanonicalDecl());
512 if (D->isInvalidDecl() && !(I == 0 && N == 1)) {
513 Decls[
I] = Decls[--N];
523 if (
TypeDecl *TD = dyn_cast<TypeDecl>(D)) {
524 QualType T = getSema().Context.getTypeDeclType(TD);
525 auto UniqueResult = UniqueTypes.insert(
527 if (!UniqueResult.second) {
529 ExistingI = UniqueResult.first->second;
536 auto UniqueResult = Unique.insert(std::make_pair(D, I));
537 if (!UniqueResult.second) {
539 ExistingI = UniqueResult.first->second;
548 Decls[*ExistingI] = Decls[
I];
549 Decls[
I] = Decls[--N];
555 if (isa<UnresolvedUsingValueDecl>(D)) {
556 HasUnresolved =
true;
557 }
else if (isa<TagDecl>(D)) {
562 }
else if (isa<FunctionTemplateDecl>(D)) {
564 HasFunctionTemplate =
true;
565 }
else if (isa<FunctionDecl>(D)) {
568 if (HasNonFunction) {
573 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
575 EquivalentNonFunctions.push_back(D);
576 Decls[
I] = Decls[--N];
596 if (N > 1 && HideTags && HasTag && !Ambiguous &&
597 (HasFunction || HasNonFunction || HasUnresolved)) {
598 NamedDecl *OtherDecl = Decls[UniqueTagIndex ? 0 : N - 1];
599 if (isa<TagDecl>(Decls[UniqueTagIndex]->getUnderlyingDecl()) &&
603 Decls[UniqueTagIndex] = Decls[--N];
610 if (!EquivalentNonFunctions.empty() && !Ambiguous)
611 getSema().diagnoseEquivalentInternalLinkageDeclarations(
612 getNameLoc(), HasNonFunction, EquivalentNonFunctions);
616 if (HasNonFunction && (HasFunction || HasUnresolved))
621 else if (HasUnresolved)
623 else if (N > 1 || HasFunctionTemplate)
629 void LookupResult::addDeclsFromBasePaths(
const CXXBasePaths &
P) {
633 DE = I->Decls.end(); DI != DE; ++DI)
640 addDeclsFromBasePaths(*Paths);
642 setAmbiguous(AmbiguousBaseSubobjects);
648 addDeclsFromBasePaths(*Paths);
650 setAmbiguous(AmbiguousBaseSubobjectTypes);
654 Out << Decls.size() <<
" result(s)";
655 if (isAmbiguous()) Out <<
", ambiguous";
656 if (Paths) Out <<
", base paths present";
665 llvm::errs() <<
"lookup results for " << getLookupName().getAsString()
732 DeclareImplicitDefaultConstructor(Class);
736 DeclareImplicitCopyConstructor(Class);
740 DeclareImplicitCopyAssignment(Class);
742 if (getLangOpts().CPlusPlus11) {
745 DeclareImplicitMoveConstructor(Class);
749 DeclareImplicitMoveAssignment(Class);
754 DeclareImplicitDestructor(Class);
785 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
788 if (Record->needsImplicitDefaultConstructor())
790 if (Record->needsImplicitCopyConstructor())
793 Record->needsImplicitMoveConstructor())
799 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC))
800 if (Record->getDefinition() && Record->needsImplicitDestructor() &&
809 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(DC)) {
812 if (Record->needsImplicitCopyAssignment())
815 Record->needsImplicitMoveAssignment())
852 !isa<CXXRecordDecl>(DC))
894 assert(ConvProto &&
"Nonsensical conversion function template type");
909 Specialization, Info)
924 assert(NS && NS->
isFileContext() &&
"CppNamespaceLookup() requires namespace!");
931 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(NS))
958 if (OuterS->getEntity()) {
959 Lexical = OuterS->getEntity();
986 if (!Lexical || !DC || !S->
getParent() ||
988 return std::make_pair(Lexical,
false);
994 while (OutermostTemplateScope->
getParent() &&
996 OutermostTemplateScope = OutermostTemplateScope->
getParent();
1010 return std::make_pair(Semantic,
true);
1012 return std::make_pair(Lexical,
false);
1018 struct FindLocalExternScope {
1020 : R(R), OldFindLocalExtern(R.getIdentifierNamespace() &
1021 Decl::IDNS_LocalExtern) {
1027 ~FindLocalExternScope() {
1031 bool OldFindLocalExtern;
1036 assert(getLangOpts().
CPlusPlus &&
"Can perform only C++ lookup");
1054 I = IdResolver.begin(Name),
1055 IEnd = IdResolver.end();
1075 UnqualUsingDirectiveSet UDirs;
1076 bool VisitedUsingDirectives =
false;
1077 bool LeftStartingScope =
false;
1081 FindLocalExternScope FindLocals(R);
1085 bool SearchNamespaceScope =
true;
1089 if (NameKind == LookupRedeclarationWithLinkage &&
1090 !(*I)->isTemplateParameter()) {
1096 if (!LeftStartingScope && !Initial->
isDeclScope(*I))
1097 LeftStartingScope =
true;
1101 if (LeftStartingScope && !((*I)->hasLinkage())) {
1108 SearchNamespaceScope =
false;
1113 if (!SearchNamespaceScope) {
1116 if (
CXXRecordDecl *Record = dyn_cast_or_null<CXXRecordDecl>(Ctx))
1121 if (NameKind == LookupLocalFriendName && !S->
isClassScope()) {
1137 Ctx = OutsideOfTemplateParamDC;
1138 OutsideOfTemplateParamDC =
nullptr;
1143 bool SearchAfterTemplateScope;
1145 if (SearchAfterTemplateScope)
1146 OutsideOfTemplateParamDC = OuterCtx;
1184 if (!VisitedUsingDirectives) {
1187 if (UCtx->isTransparentContext())
1190 UDirs.visit(UCtx, UCtx);
1195 Scope *InnermostFileScope =
S;
1196 while (InnermostFileScope &&
1198 InnermostFileScope = InnermostFileScope->
getParent();
1199 UDirs.visitScopeChain(Initial, InnermostFileScope);
1203 VisitedUsingDirectives =
true;
1220 if (LookupQualifiedName(R, Ctx,
true))
1228 if (!S)
return false;
1231 if (NameKind == LookupMemberName)
1239 if (!VisitedUsingDirectives) {
1240 UDirs.visitScopeChain(Initial, S);
1247 FindLocals.restore();
1280 Ctx = OutsideOfTemplateParamDC;
1281 OutsideOfTemplateParamDC =
nullptr;
1286 bool SearchAfterTemplateScope;
1288 if (SearchAfterTemplateScope)
1289 OutsideOfTemplateParamDC = OuterCtx;
1303 "We should have been looking only at file context here already.");
1335 Module *M = Entity->getImportedOwningModule();
1336 if (M || !isa<NamedDecl>(Entity) || !cast<NamedDecl>(Entity)->isHidden())
1338 assert(!Entity->isFromASTFile() &&
1339 "hidden entity from AST file has no owning module");
1341 if (!getLangOpts().ModulesLocalVisibility) {
1346 auto *Parent = cast<NamedDecl>(Entity->getDeclContext());
1347 assert(Parent->isHidden() &&
"unexpectedly hidden decl");
1348 return getOwningModule(Parent);
1352 M = Entity->getLocalOwningModule();
1356 if (
auto *Containing =
1357 PP.getModuleContainingLocation(Entity->getLocation())) {
1359 }
else if (Entity->isInvalidDecl() || Entity->getLocation().isInvalid()) {
1362 cast<NamedDecl>(Entity)->setHidden(
false);
1367 if (!CachedFakeTopLevelModule) {
1368 CachedFakeTopLevelModule =
1369 PP.getHeaderSearchInfo().getModuleMap().findOrCreateModule(
1370 "<top-level>",
nullptr,
false,
false).first;
1372 auto &SrcMgr = PP.getSourceManager();
1374 SrcMgr.getLocForStartOfFile(SrcMgr.getMainFileID());
1376 VisibleModulesStack.empty() ? VisibleModules : VisibleModulesStack[0];
1377 TopLevel.setVisible(CachedFakeTopLevelModule, StartLoc);
1380 M = CachedFakeTopLevelModule;
1384 Entity->setLocalOwningModule(M);
1389 if (
auto *M = PP.getModuleContainingLocation(Loc))
1397 if (
auto *TD = dyn_cast<TemplateDecl>(ND))
1398 for (
auto *Param : *TD->getTemplateParameters())
1399 makeMergedDefinitionVisible(Param, Loc);
1404 if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(Entity)) {
1409 }
else if (
CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Entity)) {
1412 }
else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Entity)) {
1415 }
else if (
VarDecl *VD = dyn_cast<VarDecl>(Entity)) {
1430 unsigned N = ActiveTemplateInstantiations.size();
1431 for (
unsigned I = ActiveTemplateInstantiationLookupModules.size();
1435 if (M && !LookupModulesCache.insert(M).second)
1437 ActiveTemplateInstantiationLookupModules.push_back(M);
1439 return LookupModulesCache;
1444 if (isModuleVisible(Merged))
1449 template<
typename ParmDecl>
1453 if (!D->hasDefaultArgument())
1457 auto &DefaultArg = D->getDefaultArgStorage();
1458 if (!DefaultArg.isInherited() && S.
isVisible(D))
1461 if (!DefaultArg.isInherited() && Modules) {
1462 auto *NonConstD =
const_cast<ParmDecl*
>(D);
1465 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1469 D = DefaultArg.getInheritedFrom();
1476 if (
auto *P = dyn_cast<TemplateTypeParmDecl>(D))
1478 if (
auto *P = dyn_cast<NonTypeTemplateParmDecl>(D))
1486 assert(isa<CXXRecordDecl>(D->getDeclContext()) &&
1487 "not a member specialization");
1488 for (
auto *Redecl : D->redecls()) {
1496 if (Redecl->getLexicalDeclContext()->isFileContext()) {
1497 auto *NonConstR =
const_cast<NamedDecl*
>(cast<NamedDecl>(Redecl));
1499 if (isVisible(NonConstR))
1503 Modules->push_back(getOwningModule(NonConstR));
1505 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1521 bool LookupResult::isVisibleSlow(
Sema &SemaRef,
NamedDecl *D) {
1522 assert(D->
isHidden() &&
"should not call this: not in slow case");
1523 Module *DeclModule =
nullptr;
1525 if (SemaRef.
getLangOpts().ModulesLocalVisibility) {
1529 assert(!D->
isHidden() &&
"hidden decl not from a module");
1536 if ((!D->isFromASTFile() || !D->isModulePrivate()) &&
1545 if (!D->isModulePrivate() &&
1550 if ((D->isTemplateParameter() || isa<ParmVarDecl>(D))
1551 ? isVisible(SemaRef, cast<NamedDecl>(DC))
1567 if (LookupModules.empty())
1572 assert(DeclModule &&
"hidden decl not from a module");
1576 if (LookupModules.count(DeclModule))
1580 if (D->isModulePrivate())
1585 return std::any_of(LookupModules.begin(), LookupModules.end(),
1586 [&](
Module *M) {
return M->isModuleVisible(DeclModule); });
1589 bool Sema::isVisibleSlow(
const NamedDecl *D) {
1612 for (
auto RD : D->redecls()) {
1617 auto ND = cast<NamedDecl>(RD);
1630 assert(!isVisible(D) &&
"not in slow case");
1632 for (
auto *Redecl : D->redecls()) {
1633 auto *NonConstR =
const_cast<NamedDecl*
>(cast<NamedDecl>(Redecl));
1634 if (isVisible(NonConstR))
1638 Modules->push_back(getOwningModule(NonConstR));
1640 Modules->insert(Modules->end(), Merged.begin(), Merged.end());
1648 if (
auto *ND = dyn_cast<NamespaceDecl>(D)) {
1655 auto *Key = ND->getCanonicalDecl();
1656 if (
auto *Acceptable = getSema().VisibleNamespaceCache.lookup(Key))
1661 getSema().VisibleNamespaceCache.insert(std::make_pair(Key, Acceptable));
1698 if (!Name)
return false;
1713 FindLocalExternScope FindLocals(R);
1719 bool LeftStartingScope =
false;
1722 IEnd = IdResolver.end();
1725 if (NameKind == LookupRedeclarationWithLinkage) {
1729 LeftStartingScope =
true;
1733 if (LeftStartingScope && !((*I)->hasLinkage())) {
1738 else if (NameKind == LookupObjCImplicitSelfParam &&
1739 !isa<ImplicitParamDecl>(*I))
1764 for (++LastI; LastI != IEnd; ++LastI) {
1789 if (CppLookupName(R, S))
1803 return (ExternalSource && ExternalSource->LookupUnqualified(R, S));
1835 assert(StartDC->
isFileContext() &&
"start context is not a file context");
1838 if (UsingDirectives.begin() == UsingDirectives.end())
return false;
1841 llvm::SmallPtrSet<DeclContext*, 8> Visited;
1842 Visited.insert(StartDC);
1850 for (
auto *I : UsingDirectives) {
1851 NamespaceDecl *ND = I->getNominatedNamespace()->getOriginalNamespace();
1852 if (Visited.insert(ND).second)
1853 Queue.push_back(ND);
1860 bool FoundTag =
false;
1861 bool FoundNonTag =
false;
1866 while (!Queue.empty()) {
1871 bool UseLocal = !R.
empty();
1900 if (Visited.insert(Nom).second)
1901 Queue.push_back(Nom);
1906 if (FoundTag && FoundNonTag)
1926 template<
typename InputIterator>
1929 if (isa<VarDecl>(D) || isa<TypeDecl>(D) || isa<EnumConstantDecl>(D))
1932 if (isa<CXXMethodDecl>(D)) {
1934 bool AllMethodsAreStatic =
true;
1935 for(; First !=
Last; ++First) {
1936 D = (*First)->getUnderlyingDecl();
1938 if (!isa<CXXMethodDecl>(D)) {
1939 assert(isa<TagDecl>(D) &&
"Non-function must be a tag decl");
1943 if (!cast<CXXMethodDecl>(D)->isStatic()) {
1944 AllMethodsAreStatic =
false;
1949 if (AllMethodsAreStatic)
1979 bool InUnqualifiedLookup) {
1980 assert(LookupCtx &&
"Sema::LookupQualifiedName requires a lookup context");
1986 assert((!isa<TagDecl>(LookupCtx) ||
1988 cast<TagDecl>(LookupCtx)->isCompleteDefinition() ||
1989 cast<TagDecl>(LookupCtx)->isBeingDefined()) &&
1990 "Declaration context must already be complete!");
1992 struct QualifiedLookupInScope {
1999 ~QualifiedLookupInScope() {
2000 Context->setUseQualifiedLookup(oldVal);
2006 if (isa<CXXRecordDecl>(LookupCtx))
2052 case LookupObjCImplicitSelfParam:
2053 case LookupOrdinaryName:
2054 case LookupMemberName:
2055 case LookupRedeclarationWithLinkage:
2056 case LookupLocalFriendName:
2068 case LookupOMPReductionName:
2072 case LookupUsingDeclName:
2075 case LookupOperatorName:
2076 case LookupNamespaceName:
2077 case LookupObjCProtocolName:
2082 case LookupNestedNameSpecifierName:
2090 return BaseCallback(Specifier, Path, Name);
2095 R.setNamingClass(LookupRec);
2104 int SubobjectNumber = 0;
2108 Path != PathEnd; ++Path) {
2113 SubobjectAccess =
std::min(SubobjectAccess, Path->Access);
2116 if (SubobjectType.isNull()) {
2133 while (FirstD != FirstPath->Decls.end() &&
2134 CurrentD != Path->Decls.end()) {
2135 if ((*FirstD)->getUnderlyingDecl()->getCanonicalDecl() !=
2136 (*CurrentD)->getUnderlyingDecl()->getCanonicalDecl())
2143 if (FirstD == FirstPath->Decls.end() &&
2144 CurrentD == Path->Decls.end())
2148 R.setAmbiguousBaseSubobjectTypes(Paths);
2164 R.setAmbiguousBaseSubobjects(Paths);
2171 for (
auto *D : Paths.front().Decls) {
2225 bool AllowBuiltinCreation,
bool EnteringContext) {
2232 if (SS && SS->
isSet()) {
2256 return LookupName(R, S, AllowBuiltinCreation);
2273 for (
const auto &BaseSpec : Class->
bases()) {
2275 BaseSpec.getType()->castAs<
RecordType>()->getDecl());
2288 Result.suppressDiagnostics();
2302 assert(Result.
isAmbiguous() &&
"Lookup result must be ambiguous");
2311 QualType SubobjectType = Paths->
front().back().Base->getType();
2312 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobjects)
2317 while (isa<CXXMethodDecl>(*Found) &&
2318 cast<CXXMethodDecl>(*Found)->isStatic())
2321 Diag((*Found)->getLocation(), diag::note_ambiguous_member_found);
2326 Diag(NameLoc, diag::err_ambiguous_member_multiple_subobject_types)
2327 << Name << LookupRange;
2330 std::set<Decl *> DeclsPrinted;
2332 PathEnd = Paths->
end();
2333 Path != PathEnd; ++Path) {
2334 Decl *D = Path->Decls.front();
2335 if (DeclsPrinted.insert(D).second)
2336 Diag(D->getLocation(), diag::note_ambiguous_member_found);
2342 Diag(NameLoc, diag::err_ambiguous_tag_hiding) << Name << LookupRange;
2344 llvm::SmallPtrSet<NamedDecl*, 8> TagDecls;
2346 for (
auto *D : Result)
2347 if (
TagDecl *TD = dyn_cast<TagDecl>(D)) {
2348 TagDecls.insert(TD);
2349 Diag(TD->getLocation(), diag::note_hidden_tag);
2352 for (
auto *D : Result)
2353 if (!isa<TagDecl>(D))
2354 Diag(D->getLocation(), diag::note_hiding_object);
2359 if (TagDecls.count(F.
next()))
2367 Diag(NameLoc, diag::err_ambiguous_reference) << Name << LookupRange;
2369 for (
auto *D : Result)
2370 Diag(D->getLocation(), diag::note_ambiguous_candidate) << D;
2377 struct AssociatedLookup {
2381 : S(S), Namespaces(Namespaces), Classes(Classes),
2382 InstantiationLoc(InstantiationLoc) {
2439 DeclContext *Ctx = ClassTemplate->getDeclContext();
2440 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2441 Result.Classes.insert(EnclosingClass);
2471 if (Class->
getDeclName() == Result.S.VAListTagName)
2484 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2485 Result.Classes.insert(EnclosingClass);
2495 if (!Result.Classes.insert(Class))
2508 = dyn_cast<ClassTemplateSpecializationDecl>(Class)) {
2509 DeclContext *Ctx = Spec->getSpecializedTemplate()->getDeclContext();
2510 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2511 Result.Classes.insert(EnclosingClass);
2516 for (
unsigned I = 0, N = TemplateArgs.
size(); I != N; ++
I)
2521 if (!Result.S.isCompleteType(Result.InstantiationLoc,
2522 Result.S.Context.getRecordType(Class)))
2528 Bases.push_back(Class);
2529 while (!Bases.empty()) {
2531 Class = Bases.pop_back_val();
2534 for (
const auto &
Base : Class->
bases()) {
2545 if (Result.Classes.insert(BaseDecl)) {
2547 DeclContext *BaseCtx = BaseDecl->getDeclContext();
2552 Bases.push_back(BaseDecl);
2580 #define TYPE(Class, Base)
2581 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
2582 #define NON_CANONICAL_TYPE(Class, Base) case Type::Class:
2583 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base) case Type::Class:
2584 #define ABSTRACT_TYPE(Class, Base)
2585 #include "clang/AST/TypeNodes.def"
2596 T = cast<PointerType>(T)->getPointeeType().getTypePtr();
2598 case Type::ConstantArray:
2599 case Type::IncompleteArray:
2600 case Type::VariableArray:
2601 T = cast<ArrayType>(T)->getElementType().getTypePtr();
2614 case Type::Record: {
2616 cast<CXXRecordDecl>(cast<RecordType>(T)->getDecl());
2626 EnumDecl *Enum = cast<EnumType>(T)->getDecl();
2629 if (
CXXRecordDecl *EnclosingClass = dyn_cast<CXXRecordDecl>(Ctx))
2630 Result.Classes.insert(EnclosingClass);
2641 case Type::FunctionProto: {
2644 Queue.push_back(Arg.getTypePtr());
2647 case Type::FunctionNoProto: {
2662 case Type::MemberPointer: {
2666 Queue.push_back(MemberPtr->
getClass());
2674 case Type::BlockPointer:
2675 T = cast<BlockPointerType>(T)->getPointeeType().getTypePtr();
2680 case Type::LValueReference:
2681 case Type::RValueReference:
2682 T = cast<ReferenceType>(T)->getPointeeType().getTypePtr();
2687 case Type::ExtVector:
2698 case Type::ObjCObject:
2699 case Type::ObjCInterface:
2700 case Type::ObjCObjectPointer:
2701 Result.Namespaces.insert(Result.S.Context.getTranslationUnitDecl());
2707 T = cast<AtomicType>(T)->getValueType().getTypePtr();
2710 T = cast<PipeType>(T)->getElementType().getTypePtr();
2716 T = Queue.pop_back_val();
2731 AssociatedNamespaces.clear();
2732 AssociatedClasses.clear();
2734 AssociatedLookup
Result(*
this, InstantiationLoc,
2735 AssociatedNamespaces, AssociatedClasses);
2744 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
2745 Expr *Arg = Args[ArgIdx];
2761 if (unaryOp->getOpcode() == UO_AddrOf)
2762 Arg = unaryOp->getSubExpr();
2767 for (
const auto *D : ULE->
decls()) {
2793 return cast_or_null<ObjCProtocolDecl>(D);
2809 assert(!Operators.
isAmbiguous() &&
"Operator lookup cannot be ambiguous");
2819 bool VolatileThis) {
2821 "doing special member lookup into record that isn't fully complete");
2823 if (RValueThis || ConstThis || VolatileThis)
2825 "constructors and destructors always have unqualified lvalue this");
2826 if (ConstArg || VolatileArg)
2828 "parameter-less special members can't have qualified arguments");
2830 llvm::FoldingSetNodeID
ID;
2833 ID.AddInteger(ConstArg);
2834 ID.AddInteger(VolatileArg);
2835 ID.AddInteger(RValueThis);
2836 ID.AddInteger(ConstThis);
2837 ID.AddInteger(VolatileThis);
2855 assert(DD &&
"record without a destructor");
2867 Expr *Arg =
nullptr;
2940 "lookup for a constructor or assignment operator was empty");
2950 for (
NamedDecl *CandDecl : Candidates) {
2951 if (CandDecl->isInvalidDecl())
2959 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2962 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2970 Tmpl, Cand, RD,
nullptr, ThisTy, Classification,
2971 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2974 CtorInfo.ConstructorTmpl, CtorInfo.FoundDecl,
nullptr,
2975 llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2978 Tmpl, Cand,
nullptr, llvm::makeArrayRef(&Arg, NumArgs), OCS,
true);
2980 assert(isa<UsingDecl>(Cand.
getDecl()) &&
2981 "illegal Kind of operator = Decl");
2988 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
2993 Result->
setMethod(cast<CXXMethodDecl>(Best->Function));
3017 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
3024 "non-const, non-volatile qualifiers for copy ctor arg");
3029 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
3039 return cast_or_null<CXXConstructorDecl>(Result->
getMethod());
3056 return Class->
lookup(Name);
3061 unsigned Quals,
bool RValueThis,
3062 unsigned ThisQuals) {
3064 "non-const, non-volatile qualifiers for copy assignment arg");
3066 "non-const, non-volatile qualifiers for copy assignment this");
3070 ThisQuals & Qualifiers::Const,
3071 ThisQuals & Qualifiers::Volatile);
3080 unsigned ThisQuals) {
3082 "non-const, non-volatile qualifiers for copy assignment this");
3086 ThisQuals & Qualifiers::Const,
3087 ThisQuals & Qualifiers::Volatile);
3100 false,
false,
false,
3113 bool AllowRaw,
bool AllowTemplate,
3114 bool AllowStringTemplate) {
3117 "literal operator lookup can't be ambiguous");
3122 bool FoundRaw =
false;
3123 bool FoundTemplate =
false;
3124 bool FoundStringTemplate =
false;
3125 bool FoundExactMatch =
false;
3127 while (F.hasNext()) {
3130 D = USD->getTargetDecl();
3133 if (D->isInvalidDecl()) {
3139 bool IsTemplate =
false;
3140 bool IsStringTemplate =
false;
3141 bool IsExactMatch =
false;
3144 if (FD->getNumParams() == 1 &&
3145 FD->getParamDecl(0)->getType()->getAs<
PointerType>())
3147 else if (FD->getNumParams() == ArgTys.size()) {
3148 IsExactMatch =
true;
3149 for (
unsigned ArgIdx = 0; ArgIdx != ArgTys.size(); ++ArgIdx) {
3150 QualType ParamTy = FD->getParamDecl(ArgIdx)->getType();
3152 IsExactMatch =
false;
3160 if (Params->
size() == 1)
3163 IsStringTemplate =
true;
3167 FoundExactMatch =
true;
3169 AllowTemplate =
false;
3170 AllowStringTemplate =
false;
3171 if (FoundRaw || FoundTemplate || FoundStringTemplate) {
3175 FoundRaw = FoundTemplate = FoundStringTemplate =
false;
3177 }
else if (AllowRaw && IsRaw) {
3179 }
else if (AllowTemplate && IsTemplate) {
3180 FoundTemplate =
true;
3181 }
else if (AllowStringTemplate && IsStringTemplate) {
3182 FoundStringTemplate =
true;
3193 if (FoundExactMatch)
3198 if (FoundRaw && FoundTemplate) {
3211 if (FoundStringTemplate)
3217 << (ArgTys.size() == 2 ? ArgTys[1] :
QualType()) << AllowRaw
3218 << (AllowTemplate || AllowStringTemplate);
3223 NamedDecl *&Old = Decls[cast<NamedDecl>(New->getCanonicalDecl())];
3227 if (Old ==
nullptr || Old == New) {
3242 if (!Cursor)
return;
3245 if (Cursor == OldFD)
break;
3260 AssociatedNamespaces,
3274 for (
auto *NS : AssociatedNamespaces) {
3290 if ((D->getIdentifierNamespace() & Decl::IDNS_Ordinary) == 0) {
3292 if ((D->getIdentifierNamespace() & Decl::IDNS_OrdinaryFriend) == 0)
3295 bool DeclaredInAssociatedClass =
false;
3296 for (
Decl *DI = D; DI; DI = DI->getPreviousDecl()) {
3298 if (isa<CXXRecordDecl>(LexDC) &&
3299 AssociatedClasses.count(cast<CXXRecordDecl>(LexDC)) &&
3301 DeclaredInAssociatedClass =
true;
3305 if (!DeclaredInAssociatedClass)
3309 if (isa<UsingShadowDecl>(D))
3310 D = cast<UsingShadowDecl>(D)->getTargetDecl();
3312 if (!isa<FunctionDecl>(D) && !isa<FunctionTemplateDecl>(D))
3332 class ShadowContextRAII;
3334 class VisibleDeclsRecord {
3339 typedef llvm::TinyPtrVector<NamedDecl*> ShadowMapEntry;
3344 typedef llvm::DenseMap<DeclarationName, ShadowMapEntry> ShadowMap;
3347 std::list<ShadowMap> ShadowMaps;
3350 llvm::SmallPtrSet<DeclContext *, 8> VisitedContexts;
3352 friend class ShadowContextRAII;
3358 return !VisitedContexts.insert(Ctx).second;
3362 return VisitedContexts.count(Ctx);
3374 ShadowMaps.back()[ND->
getDeclName()].push_back(ND);
3379 class ShadowContextRAII {
3380 VisibleDeclsRecord &Visible;
3382 typedef VisibleDeclsRecord::ShadowMap ShadowMap;
3385 ShadowContextRAII(VisibleDeclsRecord &Visible) : Visible(Visible) {
3386 Visible.ShadowMaps.emplace_back();
3389 ~ShadowContextRAII() {
3390 Visible.ShadowMaps.pop_back();
3397 unsigned IDNS = ND->getIdentifierNamespace();
3398 std::list<ShadowMap>::reverse_iterator
SM = ShadowMaps.rbegin();
3399 for (std::list<ShadowMap>::reverse_iterator SMEnd = ShadowMaps.rend();
3400 SM != SMEnd; ++
SM) {
3402 if (Pos == SM->end())
3405 for (
auto *D : Pos->second) {
3407 if (D->hasTagIdentifierNamespace() &&
3408 (IDNS & (Decl::IDNS_Member | Decl::IDNS_Ordinary |
3409 Decl::IDNS_ObjCProtocol)))
3413 if (((D->getIdentifierNamespace() & Decl::IDNS_ObjCProtocol)
3414 || (IDNS & Decl::IDNS_ObjCProtocol)) &&
3415 D->getIdentifierNamespace() != IDNS)
3423 SM == ShadowMaps.rbegin())
3435 bool QualifiedNameLookup,
3438 VisibleDeclsRecord &Visited) {
3447 if (isa<TranslationUnitDecl>(Ctx) &&
3450 auto &Idents = S.Context.Idents;
3454 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
3455 for (StringRef Name = Iter->Next(); !Name.empty(); Name = Iter->Next())
3460 for (
const auto &Ident : Idents) {
3461 for (
auto I = S.IdResolver.begin(Ident.getValue()),
3462 E = S.IdResolver.end();
3464 if (S.IdResolver.isDeclInScope(*I, Ctx)) {
3466 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3483 Consumer.
FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass);
3490 if (QualifiedNameLookup) {
3491 ShadowContextRAII Shadow(Visited);
3494 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3500 if (!Record->hasDefinition())
3503 for (
const auto &B : Record->bases()) {
3535 ShadowContextRAII Shadow(Visited);
3537 true, Consumer, Visited);
3544 for (
auto *Cat : IFace->visible_categories()) {
3545 ShadowContextRAII Shadow(Visited);
3551 for (
auto *I : IFace->all_referenced_protocols()) {
3552 ShadowContextRAII Shadow(Visited);
3558 if (IFace->getSuperClass()) {
3559 ShadowContextRAII Shadow(Visited);
3561 true, Consumer, Visited);
3566 if (IFace->getImplementation()) {
3567 ShadowContextRAII Shadow(Visited);
3569 QualifiedNameLookup, InBaseClass, Consumer, Visited);
3572 for (
auto *I : Protocol->protocols()) {
3573 ShadowContextRAII Shadow(Visited);
3578 for (
auto *I :
Category->protocols()) {
3579 ShadowContextRAII Shadow(Visited);
3585 if (
Category->getImplementation()) {
3586 ShadowContextRAII Shadow(Visited);
3588 QualifiedNameLookup,
true, Consumer, Visited);
3594 UnqualUsingDirectiveSet &UDirs,
3596 VisibleDeclsRecord &Visited) {
3602 !Visited.alreadyVisitedContext(S->
getEntity())) ||
3604 FindLocalExternScope FindLocals(Result);
3606 for (
auto *D : S->
decls()) {
3607 if (
NamedDecl *ND = dyn_cast<NamedDecl>(D))
3609 Consumer.
FoundDecl(ND, Visited.checkHidden(ND),
nullptr,
false);
3627 if (Method->isInstanceMethod()) {
3633 false, Consumer, Visited);
3647 false, Consumer, Visited);
3661 false, Consumer, Visited);
3667 for (
const UnqualUsingEntry &UUE : UDirs.getNamespacesFor(Entity))
3670 false, Consumer, Visited);
3674 ShadowContextRAII Shadow(Visited);
3680 bool IncludeGlobalScope) {
3684 UnqualUsingDirectiveSet UDirs;
3690 UDirs.visitScopeChain(Initial, S);
3697 VisibleDeclsRecord Visited;
3698 if (!IncludeGlobalScope)
3700 ShadowContextRAII Shadow(Visited);
3706 bool IncludeGlobalScope) {
3709 VisibleDeclsRecord Visited;
3710 if (!IncludeGlobalScope)
3712 ShadowContextRAII Shadow(Visited);
3714 false, Consumer, Visited);
3729 Scope *S = CurScope;
3731 return cast<LabelDecl>(Res);
3738 if (Res && Res->getDeclContext() !=
CurContext)
3744 assert(S &&
"Not in a function?");
3747 return cast<LabelDecl>(Res);
3765 bool EnteringContext,
3766 bool isObjCIvarLookup,
3778 for (; DI != DE; ++DI)
3786 bool AnyVisibleDecls = !NewDecls.empty();
3788 for (; DI != DE; ++DI) {
3794 if (!AnyVisibleDecls) {
3796 AnyVisibleDecls =
true;
3799 NewDecls.push_back(VisibleDecl);
3800 }
else if (!AnyVisibleDecls && !(*DI)->isModulePrivate())
3801 NewDecls.push_back(*DI);
3804 if (NewDecls.empty())
3821 Identifiers.clear();
3851 Identifiers.push_back(II);
3879 addName(Name,
nullptr);
3885 addName(Keyword,
nullptr,
nullptr,
true);
3888 void TypoCorrectionConsumer::addName(StringRef Name,
NamedDecl *ND,
3892 StringRef TypoStr = Typo->
getName();
3893 unsigned MinED =
abs((
int)Name.size() - (int)TypoStr.size());
3894 if (MinED && TypoStr.size() / MinED < 3)
3899 unsigned UpperBound = (TypoStr.size() + 2) / 3 + 1;
3900 unsigned ED = TypoStr.edit_distance(Name,
true, UpperBound);
3901 if (ED >= UpperBound)
return;
3912 StringRef TypoStr = Typo->
getName();
3918 if (TypoStr.size() < 3 &&
3919 (Name != TypoStr || Correction.
getEditDistance(
true) > TypoStr.size()))
3932 if (!CList.empty() && !CList.back().isResolved())
3937 RI != RIEnd; ++RI) {
3942 if (RI->getCorrectionDecl() == NewND) {
3943 if (CorrectionStr < RI->getAsString(SemaRef.
getLangOpts()))
3949 if (CList.empty() || Correction.
isResolved())
3950 CList.push_back(Correction);
3953 CorrectionResults.erase(std::prev(CorrectionResults.end()));
3957 const llvm::MapVector<NamespaceDecl *, bool> &KnownNamespaces) {
3958 SearchNamespaces =
true;
3960 for (
auto KNPair : KnownNamespaces)
3961 Namespaces.addNameSpecifier(KNPair.first);
3963 bool SSIsTemplate =
false;
3965 (SS && SS->isValid()) ? SS->getScopeRep() :
nullptr) {
3966 if (
const Type *T = NNS->getAsType())
3967 SSIsTemplate = T->getTypeClass() == Type::TemplateSpecialization;
3973 for (
unsigned I = 0; I != Types.size(); ++
I) {
3974 const auto *TI = Types[
I];
3976 CD = CD->getCanonicalDecl();
3977 if (!CD->isDependentType() && !CD->isAnonymousStructOrUnion() &&
3978 !CD->isUnion() && CD->getIdentifier() &&
3979 (SSIsTemplate || !isa<ClassTemplateSpecializationDecl>(CD)) &&
3980 (CD->isBeingDefined() || CD->isCompleteDefinition()))
3981 Namespaces.addNameSpecifier(CD);
3987 if (++CurrentTCIndex < ValidatedCorrections.size())
3988 return ValidatedCorrections[CurrentTCIndex];
3990 CurrentTCIndex = ValidatedCorrections.size();
3991 while (!CorrectionResults.empty()) {
3992 auto DI = CorrectionResults.begin();
3993 if (DI->second.empty()) {
3994 CorrectionResults.erase(DI);
3998 auto RI = DI->second.begin();
3999 if (RI->second.empty()) {
4000 DI->second.erase(RI);
4001 performQualifiedLookups();
4007 ValidatedCorrections.push_back(TC);
4008 return ValidatedCorrections[CurrentTCIndex];
4011 return ValidatedCorrections[0];
4014 bool TypoCorrectionConsumer::resolveCorrection(
TypoCorrection &Candidate) {
4021 CorrectionValidator->IsObjCIvarLookup,
4033 if (TempMemberContext) {
4036 TempMemberContext =
nullptr;
4039 if (SearchNamespaces)
4040 QualifiedResults.push_back(Candidate);
4050 for (
auto *TRD : Result)
4054 if (SearchNamespaces)
4055 QualifiedResults.push_back(Candidate);
4064 void TypoCorrectionConsumer::performQualifiedLookups() {
4065 unsigned TypoLen = Typo->
getName().size();
4067 for (
const auto &NSI : Namespaces) {
4069 const Type *NSType = NSI.NameSpecifier->getAsType();
4077 if (NSDecl->getIdentifier() == QR.getCorrectionAsIdentifierInfo())
4082 TC.ClearCorrectionDecls();
4083 TC.setCorrectionSpecifier(NSI.NameSpecifier);
4084 TC.setQualifierDistance(NSI.EditDistance);
4085 TC.setCallbackDistance(0);
4090 unsigned TmpED = TC.getEditDistance(
true);
4091 if (QR.getCorrectionAsIdentifierInfo() != Typo && TmpED &&
4092 TypoLen / TmpED < 3)
4096 Result.setLookupName(QR.getCorrectionAsIdentifierInfo());
4102 switch (Result.getResultKind()) {
4105 if (SS && SS->isValid()) {
4106 std::string NewQualified = TC.getAsString(SemaRef.
getLangOpts());
4107 std::string OldQualified;
4108 llvm::raw_string_ostream OldOStream(OldQualified);
4110 OldOStream << Typo->
getName();
4114 if (OldOStream.str() == NewQualified)
4118 TRD != TRDEnd; ++TRD) {
4123 TC.addCorrectionDecl(*TRD);
4125 if (TC.isResolved()) {
4126 TC.setCorrectionRange(SS.get(), Result.getLookupNameInfo());
4139 QualifiedResults.clear();
4142 TypoCorrectionConsumer::NamespaceSpecifierSet::NamespaceSpecifierSet(
4144 : Context(Context), CurContextChain(buildContextChain(CurContext)) {
4146 CurScopeSpec ? CurScopeSpec->
getScopeRep() :
nullptr) {
4147 llvm::raw_string_ostream SpecifierOStream(CurNameSpecifier);
4155 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4156 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C))
4163 DistanceMap[1].push_back(SI);
4166 auto TypoCorrectionConsumer::NamespaceSpecifierSet::buildContextChain(
4168 assert(Start &&
"Building a context chain from a null context");
4169 DeclContextList Chain;
4181 TypoCorrectionConsumer::NamespaceSpecifierSet::buildNestedNameSpecifier(
4183 unsigned NumSpecifiers = 0;
4185 if (
auto *ND = dyn_cast_or_null<NamespaceDecl>(C)) {
4188 }
else if (
auto *RD = dyn_cast_or_null<RecordDecl>(C)) {
4190 RD->getTypeForDecl());
4194 return NumSpecifiers;
4197 void TypoCorrectionConsumer::NamespaceSpecifierSet::addNameSpecifier(
4200 unsigned NumSpecifiers = 0;
4201 DeclContextList NamespaceDeclChain(buildContextChain(Ctx));
4202 DeclContextList FullNamespaceDeclChain(NamespaceDeclChain);
4205 for (
DeclContext *C : llvm::reverse(CurContextChain)) {
4206 if (NamespaceDeclChain.empty() || NamespaceDeclChain.back() !=
C)
4208 NamespaceDeclChain.pop_back();
4212 NumSpecifiers = buildNestedNameSpecifier(NamespaceDeclChain, NNS);
4215 if (NamespaceDeclChain.empty()) {
4219 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4221 dyn_cast_or_null<NamedDecl>(NamespaceDeclChain.back())) {
4223 bool SameNameSpecifier =
false;
4224 if (std::find(CurNameSpecifierIdentifiers.begin(),
4225 CurNameSpecifierIdentifiers.end(),
4226 Name) != CurNameSpecifierIdentifiers.end()) {
4227 std::string NewNameSpecifier;
4228 llvm::raw_string_ostream SpecifierOStream(NewNameSpecifier);
4232 SpecifierOStream.flush();
4233 SameNameSpecifier = NewNameSpecifier == CurNameSpecifier;
4235 if (SameNameSpecifier ||
4236 std::find(CurContextIdentifiers.begin(), CurContextIdentifiers.end(),
4237 Name) != CurContextIdentifiers.end()) {
4241 buildNestedNameSpecifier(FullNamespaceDeclChain, NNS);
4249 if (NNS && !CurNameSpecifierIdentifiers.empty()) {
4252 NumSpecifiers = llvm::ComputeEditDistance(
4253 llvm::makeArrayRef(CurNameSpecifierIdentifiers),
4254 llvm::makeArrayRef(NewNameSpecifierIdentifiers));
4257 SpecifierInfo SI = {Ctx, NNS, NumSpecifiers};
4258 DistanceMap[NumSpecifiers].push_back(SI);
4267 bool EnteringContext,
4268 bool isObjCIvarLookup,
4274 if (MemberContext) {
4276 if (isObjCIvarLookup) {
4277 if (
ObjCIvarDecl *Ivar = Class->lookupInstanceVariable(Name)) {
4302 if (Method->isInstanceMethod() && Method->getClassInterface() &&
4305 Res.
getFoundDecl()->isDefinedOutsideFunctionOrMethod()))) {
4307 = Method->getClassInterface()->lookupInstanceVariable(Name)) {
4319 bool AfterNestedNameSpecifier) {
4320 if (AfterNestedNameSpecifier) {
4333 static const char *
const CTypeSpecs[] = {
4334 "char",
"const",
"double",
"enum",
"float",
"int",
"long",
"short",
4335 "signed",
"struct",
"union",
"unsigned",
"void",
"volatile",
4336 "_Complex",
"_Imaginary",
4338 "extern",
"inline",
"static",
"typedef"
4341 const unsigned NumCTypeSpecs = llvm::array_lengthof(CTypeSpecs);
4342 for (
unsigned I = 0; I != NumCTypeSpecs; ++
I)
4369 static const char *
const CastableTypeSpecs[] = {
4370 "char",
"double",
"float",
"int",
"long",
"short",
4371 "signed",
"unsigned",
"void"
4373 for (
auto *kw : CastableTypeSpecs)
4392 static const char *
const CXXExprs[] = {
4393 "delete",
"new",
"operator",
"throw",
"typeid"
4395 const unsigned NumCXXExprs = llvm::array_lengthof(CXXExprs);
4396 for (
unsigned I = 0; I != NumCXXExprs; ++
I)
4399 if (isa<CXXMethodDecl>(SemaRef.
CurContext) &&
4400 cast<CXXMethodDecl>(SemaRef.
CurContext)->isInstance())
4419 static const char *
const CStmts[] = {
4420 "do",
"else",
"for",
"goto",
"if",
"return",
"switch",
"while" };
4421 const unsigned NumCStmts = llvm::array_lengthof(CStmts);
4422 for (
unsigned I = 0; I != NumCStmts; ++
I)
4466 std::unique_ptr<TypoCorrectionConsumer> Sema::makeTypoCorrectionConsumer(
4469 std::unique_ptr<CorrectionCandidateCallback> CCC,
4506 locs->second.count(TypoName.
getLoc()))
4533 auto Consumer = llvm::make_unique<TypoCorrectionConsumer>(
4534 *
this, TypoName, LookupKind,
S, SS, std::move(CCC), MemberContext,
4538 bool IsUnqualifiedLookup =
false;
4540 if (MemberContext) {
4545 for (
auto *I : OPT->
quals())
4548 }
else if (SS && SS->isSet()) {
4555 IsUnqualifiedLookup =
true;
4560 bool SearchNamespaces
4562 (IsUnqualifiedLookup || (SS && SS->isSet()));
4564 if (IsUnqualifiedLookup || SearchNamespaces) {
4568 for (
const auto &I : Context.
Idents)
4575 std::unique_ptr<IdentifierIterator> Iter(External->getIdentifiers());
4577 StringRef Name = Iter->Next();
4590 if (SearchNamespaces) {
4592 if (ExternalSource && !LoadedExternalKnownNamespaces) {
4594 LoadedExternalKnownNamespaces =
true;
4596 for (
auto *N : ExternalKnownNamespaces)
4597 KnownNamespaces[N] =
true;
4600 Consumer->addNamespaces(KnownNamespaces);
4640 std::unique_ptr<CorrectionCandidateCallback> CCC,
4643 bool EnteringContext,
4645 bool RecordFailure) {
4646 assert(CCC &&
"CorrectTypo requires a CorrectionCandidateCallback");
4650 if (ExternalSource) {
4652 TypoName, LookupKind, S, SS, *CCC, MemberContext, EnteringContext, OPT))
4660 bool ObjCMessageReceiver = CCC->WantObjCSuper && !CCC->WantRemainingKeywords;
4663 auto Consumer = makeTypoCorrectionConsumer(
4664 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4672 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4676 unsigned ED =
Consumer->getBestEditDistance(
true);
4677 unsigned TypoLen = Typo->
getName().size();
4678 if (ED > 0 && TypoLen / ED < 3)
4679 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4684 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4686 ED = BestTC.getEditDistance();
4688 if (TypoLen >= 3 && ED > 0 && TypoLen / ED < 3) {
4692 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4696 if (!SecondBestTC ||
4697 SecondBestTC.
getEditDistance(
false) > BestTC.getEditDistance(
false)) {
4703 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4709 }
else if (SecondBestTC && ObjCMessageReceiver) {
4713 if (BestTC.getCorrection().getAsString() !=
"super") {
4715 BestTC = SecondBestTC;
4716 else if ((*
Consumer)[
"super"].front().isKeyword())
4717 BestTC = (*
Consumer)[
"super"].front();
4721 if (BestTC.getEditDistance() == 0 ||
4722 BestTC.getCorrection().getAsString() !=
"super")
4723 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure);
4732 return FailedCorrection(Typo, TypoName.
getLoc(), RecordFailure && !SecondBestTC);
4776 std::unique_ptr<CorrectionCandidateCallback> CCC,
4780 assert(CCC &&
"CorrectTypoDelayed requires a CorrectionCandidateCallback");
4782 auto Consumer = makeTypoCorrectionConsumer(
4783 TypoName, LookupKind, S, SS, std::move(CCC), MemberContext,
4790 TypoName, LookupKind, S, SS, *
Consumer->getCorrectionValidator(),
4791 MemberContext, EnteringContext, OPT);
4793 Consumer->addCorrection(ExternalTypo);
4801 unsigned ED =
Consumer->getBestEditDistance(
true);
4803 if (!ExternalTypo && ED > 0 && Typo->
getName().size() / ED < 3)
4807 return createDelayedTypo(std::move(
Consumer), std::move(TDG), std::move(TRC));
4814 CorrectionDecls.clear();
4816 CorrectionDecls.push_back(CDecl);
4818 if (!CorrectionName)
4823 if (CorrectionNameSpec) {
4824 std::string tmpBuffer;
4825 llvm::raw_string_ostream PrefixOStream(tmpBuffer);
4827 PrefixOStream << CorrectionName;
4828 return PrefixOStream.str();
4843 bool HasNonType =
false;
4844 bool HasStaticMethod =
false;
4845 bool HasNonStaticMethod =
false;
4846 for (
Decl *D : candidate) {
4848 D = FTD->getTemplatedDecl();
4850 if (Method->isStatic())
4851 HasStaticMethod =
true;
4853 HasNonStaticMethod =
true;
4855 if (!isa<TypeDecl>(D))
4860 !candidate.getCorrectionSpecifier())
4867 bool HasExplicitTemplateArgs,
4869 : NumArgs(NumArgs), HasExplicitTemplateArgs(HasExplicitTemplateArgs),
4870 CurContext(SemaRef.CurContext), MemberFn(ME) {
4880 for (
auto *C : candidate) {
4884 FD = FTD->getTemplatedDecl();
4885 if (!HasExplicitTemplateArgs && !FD) {
4886 if (!(FD = dyn_cast<FunctionDecl>(ND)) && isa<ValueDecl>(ND)) {
4890 QualType ValType = cast<ValueDecl>(ND)->getType();
4894 if (FPT->getNumParams() == NumArgs)
4910 if (MemberFn || !MD->isStatic()) {
4913 ? dyn_cast_or_null<CXXMethodDecl>(MemberFn->
getMemberDecl())
4914 : dyn_cast_or_null<CXXMethodDecl>(CurContext);
4929 bool ErrorRecovery) {
4937 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
4938 return VD->getDefinition();
4940 return FD->getDefinition();
4941 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
4942 return TD->getDefinition();
4944 return ID->getDefinition();
4946 return PD->getDefinition();
4954 assert(!
isVisible(Decl) &&
"missing import for non-hidden decl?");
4963 assert(Owner &&
"definition of hidden declaration is not in a module");
4966 OwningModules.push_back(Owner);
4968 OwningModules.insert(OwningModules.end(), Merged.begin(), Merged.end());
4981 return (IsSystem ?
'<' :
'"') + Path + (IsSystem ?
'>' :
'"');
4988 assert(!Modules.empty());
4990 if (Modules.size() > 1) {
4991 std::string ModuleList;
4993 for (
Module *M : Modules) {
4994 ModuleList +=
"\n ";
4995 if (++N == 5 && N != Modules.size()) {
4996 ModuleList +=
"[...]";
4999 ModuleList += M->getFullModuleName();
5002 Diag(UseLoc, diag::err_module_unimported_use_multiple)
5003 << (int)MIK << Decl << ModuleList;
5011 Diag(UseLoc, diag::err_module_unimported_use_header)
5012 << (int)MIK << Decl << Modules[0]->getFullModuleName()
5016 Diag(UseLoc, diag::err_module_unimported_use)
5017 << (int)MIK << Decl << Modules[0]->getFullModuleName();
5023 DiagID = diag::note_previous_declaration;
5026 DiagID = diag::note_previous_definition;
5029 DiagID = diag::note_default_argument_declared_here;
5032 DiagID = diag::note_explicit_specialization_declared_here;
5035 DiagID = diag::note_partial_specialization_declared_here;
5038 Diag(DeclLoc, DiagID);
5060 bool ErrorRecovery) {
5069 assert(Decl &&
"import required but no declaration to import");
5077 << CorrectedQuotedStr << (ErrorRecovery ? FixTypo :
FixItHint());
5082 Diag(ChosenDecl->getLocation(), PrevNote)
5083 << CorrectedQuotedStr << (ErrorRecovery ?
FixItHint() : FixTypo);
5086 TypoExpr *Sema::createDelayedTypo(std::unique_ptr<TypoCorrectionConsumer> TCC,
5087 TypoDiagnosticGenerator TDG,
5088 TypoRecoveryCallback TRC) {
5089 assert(TCC &&
"createDelayedTypo requires a valid TypoCorrectionConsumer");
5091 auto &
State = DelayedTypos[TE];
5092 State.Consumer = std::move(TCC);
5093 State.DiagHandler = std::move(TDG);
5094 State.RecoveryHandler = std::move(TRC);
5099 auto Entry = DelayedTypos.find(TE);
5100 assert(Entry != DelayedTypos.end() &&
5101 "Failed to get the state for a TypoExpr!");
5102 return Entry->second;
5106 DelayedTypos.erase(TE);
unsigned getFlags() const
getFlags - Return the flags for this scope.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
Defines the clang::ASTContext interface.
Module * getOwningModule(Decl *Entity)
Get the module owning an entity.
Name lookup results in an ambiguity because multiple definitions of entity that meet the lookup crite...
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
bool isDerivedFrom(const CXXRecordDecl *Base) const
Determine whether this class is derived from the class Base.
FunctionCallFilterCCC(Sema &SemaRef, unsigned NumArgs, bool HasExplicitTemplateArgs, MemberExpr *ME=nullptr)
Name lookup found a set of overloaded functions that met the criteria.
bool isTransparentContext() const
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
bool needsImplicitMoveConstructor() const
Determine whether this class should get an implicit move constructor or if any existing special membe...
void setOrigin(CXXRecordDecl *Rec)
no exception specification
IdentifierInfo * getSuperIdentifier() const
llvm::iterator_range< pack_iterator > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
PointerType - C99 6.7.5.1 - Pointer Declarators.
A (possibly-)qualified type.
Simple class containing the result of Sema::CorrectTypo.
void setHidden(bool Hide)
Set whether this declaration is hidden from name lookup.
ExtInfo withCallingConv(CallingConv cc) const
QualType getType() const
Retrieves the type of the base class.
virtual unsigned RankCandidate(const TypoCorrection &candidate)
Method used by Sema::CorrectTypo to assign an "edit distance" rank to a candidate (where a lower valu...
Template argument deduction was successful.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
DeclClass * getAsSingle() const
Look up the name of an Objective-C protocol.
Filter makeFilter()
Create a filter for this result set.
CXXMethodDecl * LookupMovingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the moving assignment operator for the given class.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Provides information about an attempted template argument deduction, whose success or failure was des...
const Scope * getParent() const
getParent - Return the scope that this is nested in.
void addConst()
Add the const type qualifier to this QualType.
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void ForceDeclarationOfImplicitMembers(CXXRecordDecl *Class)
Force the declaration of any implicitly-declared members of this class.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
void erase()
Erase the last element returned from this iterator.
ConstructorInfo getConstructorInfo(NamedDecl *ND)
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
__DEVICE__ long long abs(long long __n)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
Name lookup results in an ambiguity because multiple nonstatic entities that meet the lookup criteria...
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Defines the C++ template declaration subclasses.
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
void swap(CXXBasePaths &Other)
Swap this data structure's contents with another CXXBasePaths object.
QualType getPointeeType() const
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
CXXRecordDecl * getAsRecordDecl() const
Retrieve the record declaration stored in this nested name specifier.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
MissingImportKind
Kinds of missing import.
QualType getRecordType(const RecordDecl *Decl) const
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
NamespaceDecl - Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
Ambiguous candidates found.
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
Look up of a name that precedes the '::' scope resolution operator in C++.
void makeKeyword()
Mark this TypoCorrection as being a keyword.
Scope * getContinueParent()
getContinueParent - Return the closest scope that a continue statement would be affected by...
bool needsImplicitDestructor() const
Determine whether this class needs an implicit destructor to be lazily declared.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
LiteralOperatorLookupResult
The possible outcomes of name lookup for a literal operator.
Represents a C++ constructor within a class.
Look up a namespace name within a C++ using directive or namespace alias definition, ignoring non-namespace names (C++ [basic.lookup.udir]p1).
void ArgumentDependentLookup(DeclarationName Name, SourceLocation Loc, ArrayRef< Expr * > Args, ADLResult &Functions)
CXXMethodDecl * DeclareImplicitMoveAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit move assignment operator for the given class.
Consumes visible declarations found when searching for all visible names within a given scope or cont...
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
An identifier, stored as an IdentifierInfo*.
CXXConstructorDecl * LookupMovingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the moving constructor for the given class.
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
static bool LookupBuiltin(Sema &S, LookupResult &R)
Lookup a builtin function, when name lookup would otherwise fail.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
CXXMethodDecl * LookupCopyingAssignment(CXXRecordDecl *Class, unsigned Quals, bool RValueThis, unsigned ThisQuals)
Look up the copying assignment operator for the given class.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
SmallVector< SwitchStmt *, 8 > SwitchStack
SwitchStack - This is the current set of active switch statements in the block.
static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, bool QualifiedNameLookup, bool InBaseClass, VisibleDeclConsumer &Consumer, VisibleDeclsRecord &Visited)
DiagnosticsEngine & Diags
static bool HasOnlyStaticMembers(InputIterator First, InputIterator Last)
Determine whether the given set of member declarations contains only static members, nested types, and enumerators.
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Represents an empty template argument, e.g., one that has not been deduced.
Extra information about a function prototype.
static bool CanDeclareSpecialMemberFunction(const CXXRecordDecl *Class)
Determine whether we can declare a special member function within the class at this point...
void setNotFoundInCurrentInstantiation()
Note that while no result was found in the current instantiation, there were dependent base classes t...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
static bool FindOMPReductionMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists an OpenMP declare reduction member wi...
A namespace, stored as a NamespaceDecl*.
The lookup found a single 'cooked' literal operator, which expects a normal literal to be built and p...
udir_range using_directives() const
Returns iterator range [First, Last) of UsingDirectiveDecls stored within this context.
SpecialMemberOverloadResult * LookupSpecialMember(CXXRecordDecl *D, CXXSpecialMember SM, bool ConstArg, bool VolatileArg, bool RValueThis, bool ConstThis, bool VolatileThis)
Stores a list of template parameters for a TemplateDecl and its derived classes.
Describes how types, statements, expressions, and declarations should be printed. ...
virtual TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, int LookupKind, Scope *S, CXXScopeSpec *SS, CorrectionCandidateCallback &CCC, DeclContext *MemberContext, bool EnteringContext, const ObjCObjectPointerType *OPT)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
Look up an ordinary name that is going to be redeclared as a name with linkage.
Defines the clang::Expr interface and subclasses for C++ expressions.
const CXXRecordDecl * getTemplateInstantiationPattern() const
Retrieve the record declaration from which this record could be instantiated.
void addKeywordResult(StringRef Keyword)
bool WantExpressionKeywords
std::list< CXXBasePath >::const_iterator const_paths_iterator
void setMethod(CXXMethodDecl *MD)
const SmallVectorImpl< Type * > & getTypes() const
static Decl * getInstantiatedFrom(Decl *D, MemberSpecializationInfo *MSInfo)
Find the declaration that a class temploid member specialization was instantiated from...
RecordDecl - Represents a struct/union/class.
static bool hasVisibleDefaultArgument(Sema &S, const ParmDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
bool LookupInSuper(LookupResult &R, CXXRecordDecl *Class)
Perform qualified name lookup into all base classes of the given class.
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
The lookup found a single 'raw' literal operator, which expects a string literal containing the spell...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
IdentifierInfo * getCorrectionAsIdentifierInfo() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
The results of name lookup within a DeclContext.
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
bool isReferenceType() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
void setAmbiguousBaseSubobjectTypes(CXXBasePaths &P)
Make these results show that the name was found in base classes of different types.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
void LookupVisibleDecls(Scope *S, LookupNameKind Kind, VisibleDeclConsumer &Consumer, bool IncludeGlobalScope=true)
bool isAnyPointerType() const
IdentifierSourceLocations TypoCorrectionFailures
A cache containing identifiers for which typo correction failed and their locations, so that repeated attempts to correct an identifier in a given location are ignored if typo correction already failed for it.
void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass) override
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
SourceRange getContextRange() const
Gets the source range of the context of this name; for C++ qualified lookups, this is the source rang...
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
unsigned size() const
Retrieve the number of template arguments in this template argument list.
The iterator over UnresolvedSets.
void addCorrectionDecl(NamedDecl *CDecl)
Add the given NamedDecl to the list of NamedDecls that are the declarations associated with the Decla...
bool isInlineNamespace() const
bool needsImplicitCopyAssignment() const
Determine whether this class needs an implicit copy assignment operator to be lazily declared...
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
Scope * getBreakParent()
getBreakParent - Return the closest scope that a break statement would be affected by...
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Describes a module or submodule.
llvm::BumpPtrAllocator BumpAlloc
SpecialMemberOverloadResult - The overloading result for a special member function.
void setCallbackDistance(unsigned ED)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
unsigned TyposCorrected
The number of typos corrected by CorrectTypo.
void AddMethodTemplateCandidate(FunctionTemplateDecl *MethodTmpl, DeclAccessPair FoundDecl, CXXRecordDecl *ActingContext, TemplateArgumentListInfo *ExplicitTemplateArgs, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ member function template as a candidate to the candidate set, using template argument deduc...
param_type_range param_types() const
Look up implicit 'self' parameter of an objective-c method.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
Represents the results of name lookup.
void setAmbiguousBaseSubobjects(CXXBasePaths &P)
Make these results show that the name was found in distinct base classes of the same type...
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
static void LookupPotentialTypoResult(Sema &SemaRef, LookupResult &Res, IdentifierInfo *Name, Scope *S, CXXScopeSpec *SS, DeclContext *MemberContext, bool EnteringContext, bool isObjCIvarLookup, bool FindHidden)
Perform name lookup for a possible result for typo correction.
Succeeded, but refers to a deleted function.
unsigned getDiagID() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
static void DeclareImplicitMemberFunctionsWithName(Sema &S, DeclarationName Name, const DeclContext *DC)
If there are any implicit member functions with the given name that need to be declared in the given ...
CXXConstructorDecl * DeclareImplicitMoveConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit move constructor for the given class.
QualType getReturnType() const
Look up all declarations in a scope with the given name, including resolved using declarations...
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
static NamedDecl * getDefinitionToImport(NamedDecl *D)
Find which declaration we should import to provide the definition of the given declaration.
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
AmbiguityKind getAmbiguityKind() const
IdentifierInfo * getTypePackElementName() const
virtual bool includeHiddenDecls() const
Determine whether hidden declarations (from unimported modules) should be given to this consumer...
The lookup found an overload set of literal operator templates, which expect the character type and c...
HeaderSearch & getHeaderSearchInfo() const
TypeDecl - Represents a declaration of a type.
A set of unresolved declarations.
RecordDecl * getDecl() const
FunctionDecl * getTemplateInstantiationPattern() const
Retrieve the function declaration from which this function could be instantiated, if it is an instant...
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
static unsigned getIDNS(Sema::LookupNameKind NameKind, bool CPlusPlus, bool Redeclaration)
Look up the name of an OpenMP user-defined reduction operation.
std::function< ExprResult(Sema &, TypoExpr *, TypoCorrection)> TypoRecoveryCallback
Scope - A scope is a transient data structure that is used while parsing the program.
void DiagnoseAmbiguousLookup(LookupResult &Result)
Produce a diagnostic describing the ambiguity that resulted from name lookup.
CXXRecordDecl * getCanonicalDecl() override
std::string getQuoted(const LangOptions &LO) const
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
using_directives_range using_directives()
void append(iterator I, iterator E)
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
base_class_iterator bases_begin()
CXXBasePaths * getBasePaths() const
Return the base paths structure that's associated with these results, or null if none is...
Represents an Objective-C protocol declaration.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
LabelDecl * LookupOrCreateLabel(IdentifierInfo *II, SourceLocation IdentLoc, SourceLocation GnuLabelLoc=SourceLocation())
LookupOrCreateLabel - Do a name lookup of a label with the specified name.
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
const TypoCorrection & getNextCorrection()
Return the next typo correction that passes all internal filters and is deemed valid by the consumer'...
Represents an ObjC class declaration.
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
detail::InMemoryDirectory::const_iterator I
QualType getCanonicalTypeInternal() const
SourceRange getRange() const
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
CXXMethodDecl * getMethod() const
static const unsigned InvalidDistance
CXXSpecialMember
Kinds of C++ special members.
bool WantRemainingKeywords
Sema - This implements semantic analysis and AST building for C.
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
virtual void FoundDecl(NamedDecl *ND, NamedDecl *Hiding, DeclContext *Ctx, bool InBaseClass)=0
Invoked each time Sema::LookupVisibleDecls() finds a declaration visible from the current scope or co...
bool hasVisibleDefaultArgument(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if the template parameter D has a visible default argument.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
Represents a prototype with parameter type info, e.g.
llvm::iterator_range< decls_iterator > decls() const
ArrayRef< Module * > getModulesWithMergedDefinition(NamedDecl *Def)
Get the additional modules in which the definition Def has been merged.
The return type of classify().
bool needsImplicitMoveAssignment() const
Determine whether this class should get an implicit move assignment operator or if any existing speci...
DeclarationNameTable DeclarationNames
Provides lookups to, and iteration over, IdentiferInfo objects.
bool hasVisibleDeclarationSlow(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules)
NamedDecl * getDecl() const
lookups_range lookups() const
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
std::function< void(const TypoCorrection &)> TypoDiagnosticGenerator
static bool LookupAnyMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Callback that looks for any member of a class with the given name.
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...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
virtual bool ValidateCandidate(const TypoCorrection &candidate)
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
static bool LookupQualifiedNameInUsingDirectives(Sema &S, LookupResult &R, DeclContext *StartDC)
Perform qualified name lookup in the namespaces nominated by using directives by the given context...
bool isDeleted() const
Whether this function has been deleted.
Expr - This represents one expression.
Defines the clang::LangOptions interface.
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
StringRef getName() const
Return the actual identifier string.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool hasFatalErrorOccurred() const
llvm::iterator_range< udir_iterator > udir_range
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
int SubobjectNumber
Identifies which base class subobject (of type Base->getType()) this base path element refers to...
void setHideTags(bool Hide)
Sets whether tag declarations should be hidden by non-tag declarations during resolution.
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isModuleVisible(Module *M)
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
conversion_iterator conversion_end() const
Represents a C++ destructor within a class.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
void setRequiresImport(bool Req)
ArgKind getKind() const
Return the kind of stored template argument.
ExtProtoInfo getExtProtoInfo() const
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
static bool FindNestedNameSpecifierMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name that can...
Overload resolution succeeded.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Represents a C++ template name within the type system.
char __ovld __cnfn min(char x, char y)
Returns y if y < x, otherwise it returns x.
A namespace alias, stored as a NamespaceAliasDecl*.
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isFunctionOrMethod() const
NamedDecl * getAcceptableDecl(NamedDecl *D) const
Retrieve the accepted (re)declaration of the given declaration, if there is one.
static NamedDecl * findAcceptableDecl(Sema &SemaRef, NamedDecl *D)
Retrieve the visible declaration corresponding to D, if any.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion, return the pattern as a template name.
void addCorrection(TypoCorrection Correction)
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
static bool FindOrdinaryMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a member with the given name...
bool isExternallyVisible() const
void diagnoseMissingImport(SourceLocation Loc, NamedDecl *Decl, MissingImportKind MIK, bool Recover=true)
Diagnose that the specified declaration needs to be visible but isn't, and suggest a module import th...
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
DiagnosticsEngine & getDiagnostics() const
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
BuiltinTemplateDecl * getMakeIntegerSeqDecl() const
The result type of a method or function.
llvm::FoldingSet< SpecialMemberOverloadResult > SpecialMemberCache
A cache of special member function overload resolution results for C++ records.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
A type, stored as a Type*.
CXXConstructorDecl * LookupCopyingConstructor(CXXRecordDecl *Class, unsigned Quals)
Look up the copying constructor for the given class.
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
const clang::PrintingPolicy & getPrintingPolicy() const
Name lookup results in an ambiguity because multiple entities that meet the lookup criteria were foun...
const TypoExprState & getTypoExprState(TypoExpr *TE) const
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
virtual bool lookupMissingImports(StringRef Name, SourceLocation TriggerLoc)=0
Check global module index for missing imports.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
static bool isImplicitlyDeclaredMemberFunctionName(DeclarationName Name)
Determine whether this is the name of an implicitly-declared special member function.
NamespaceDecl * getAsNamespace() const
Retrieve the namespace stored in this nested name specifier.
const CXXBaseSpecifier * Base
The base specifier that states the link from a derived class to a base class, which will be followed ...
static Module * getDefiningModule(Sema &S, Decl *Entity)
Find the module in which the given declaration was defined.
DeclContext * getEntity() const
NamedDecl * getInstantiatedFrom() const
Retrieve the member declaration from which this member was instantiated.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Tag name lookup, which finds the names of enums, classes, structs, and unions.
void setCorrectionDecls(ArrayRef< NamedDecl * > Decls)
Clears the list of NamedDecls and adds the given set.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
Encodes a location in the source.
void addVolatile()
Add the volatile type qualifier to this QualType.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static std::string getIncludeStringForHeader(Preprocessor &PP, const FileEntry *E)
Get a "quoted.h" or <angled.h> include path to use in a diagnostic suggesting the addition of a #incl...
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
void FindAssociatedClassesAndNamespaces(SourceLocation InstantiationLoc, ArrayRef< Expr * > Args, AssociatedNamespaceSet &AssociatedNamespaces, AssociatedClassSet &AssociatedClasses)
Find the associated classes and namespaces for argument-dependent lookup for a call with the given se...
const TemplateArgument * iterator
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
static void getNestedNameSpecifierIdentifiers(NestedNameSpecifier *NNS, SmallVectorImpl< const IdentifierInfo * > &Identifiers)
TagDecl - Represents the declaration of a struct/union/class/enum.
IdentifierInfo * getMakeIntegerSeqName() const
ASTContext & getASTContext() const
void FoundName(StringRef Name)
LabelDecl - Represents the declaration of a label.
Cached information about one file (either on disk or in the virtual file system). ...
bool hasVisibleMergedDefinition(NamedDecl *Def)
Represents a static or instance method of a struct/union/class.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
bool isInvalid() const
An error occurred during parsing of the scope specifier.
std::string getAmbiguousPathsDisplayString(CXXBasePaths &Paths)
Builds a string representing ambiguous paths from a specific derived class to different subobjects of...
Name lookup found an unresolvable value declaration and cannot yet complete.
llvm::DenseSet< Module * > & getLookupModules()
Get the set of additional modules that should be checked during name lookup.
ObjCCategoryDecl - Represents a category declaration.
bool isTemplateParamScope() const
isTemplateParamScope - Return true if this scope is a C++ template parameter scope.
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Look up any declaration with any name.
A class for iterating through a result set and possibly filtering out results.
Represents one property declaration in an Objective-C interface.
DiagnosticOptions & getDiagnosticOptions() const
Retrieve the diagnostic options.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=NotForRedeclaration)
Find the protocol with the given name, if any.
NamespaceAliasDecl * getAsNamespaceAlias() const
Retrieve the namespace alias stored in this nested name specifier.
SourceLocation getBegin() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
No entity found met the criteria.
bool isFileContext() const
sema::FunctionScopeInfo * getCurFunction() const
static bool canHideTag(NamedDecl *D)
Determine whether D can hide a tag declaration.
bool RequireCompleteDeclContext(CXXScopeSpec &SS, DeclContext *DC)
Require that the context specified by SS be complete.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
void NoteOverloadCandidate(NamedDecl *Found, FunctionDecl *Fn, QualType DestType=QualType(), bool TakingAddress=false)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
CXXDestructorDecl * DeclareImplicitDestructor(CXXRecordDecl *ClassDecl)
Declare the implicit destructor for the given class.
A POD class for pairing a NamedDecl* with an access specifier.
A class for storing results from argument-dependent lookup.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery...
Represents an element in a path from a derived class to a base class.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
Represents a template argument.
static void CollectEnclosingNamespace(Sema::AssociatedNamespaceSet &Namespaces, DeclContext *Ctx)
static DeclContext * getContextForScopeMatching(Decl *D)
Get a representative context for a declaration such that two declarations will have the same context ...
QualType getAsType() const
Retrieve the type for a type template argument.
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
NamespaceDecl * getNominatedNamespace()
Returns the namespace nominated by this using-directive.
void print(raw_ostream &OS, const PrintingPolicy &Policy) const
Print this nested name specifier to the given output stream.
void setAllowHidden(bool AH)
Specify whether hidden declarations are visible, e.g., for recovery reasons.
CXXConstructorDecl * DeclareImplicitCopyConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit copy constructor for the given class.
SourceLocation getLocStart() const LLVM_READONLY
static void checkCorrectionVisibility(Sema &SemaRef, TypoCorrection &TC)
Check whether the declarations found for a typo correction are visible, and if none of them are...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
static void AddKeywordsToConsumer(Sema &SemaRef, TypoCorrectionConsumer &Consumer, Scope *S, CorrectionCandidateCallback &CCC, bool AfterNestedNameSpecifier)
Add keywords to the consumer as possible typo corrections.
The base class of all kinds of template declarations (e.g., class, function, etc.).
void setContextRange(SourceRange SR)
Sets a 'context' source range.
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
unsigned getIdentifierNamespace() const
Returns the identifier namespace mask for this lookup.
The template argument is a pack expansion of a template name that was provided for a template templat...
bool isExplicitSpecialization() const
void setAmbiguousQualifiedTagHiding()
Make these results show that the name was found in different contexts and a tag decl was hidden by an...
void clearDelayedTypo(TypoExpr *TE)
Clears the state of the given TypoExpr.
void makeMergedDefinitionVisible(NamedDecl *ND, SourceLocation Loc)
Make a merged definition of an existing hidden definition ND visible at the specified location...
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
void insert(NamedDecl *D)
Adds a new ADL candidate to this map.
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
DeclarationName - The name of a declaration.
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
U cast(CodeGen::Address addr)
EnumDecl - Represents an enum.
static const unsigned MaxTypoDistanceResultSets
The lookup found an overload set of literal operator templates, which expect the characters of the sp...
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
BuiltinTemplateDecl * getTypePackElementDecl() const
static LabelDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation IdentL, IdentifierInfo *II)
CXXConstructorDecl * DeclareImplicitDefaultConstructor(CXXRecordDecl *ClassDecl)
Declare the implicit default constructor for the given class.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
bool empty() const
Return true if no decls were found.
Name lookup found a single declaration that met the criteria.
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
bool isInObjcMethodScope() const
isInObjcMethodScope - Return true if this scope is, or is contained in, an Objective-C method body...
static AccessSpecifier MergeAccess(AccessSpecifier PathAccess, AccessSpecifier DeclAccess)
Calculates the access of a decl that is reached along a path.
bool hasVisibleMemberSpecialization(const NamedDecl *D, llvm::SmallVectorImpl< Module * > *Modules=nullptr)
Determine if there is a visible declaration of D that is a member specialization declaration (as oppo...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
const T * getAs() const
Member-template getAs<specific type>'.
PrintingPolicy getPrintingPolicy() const
Retrieve a suitable printing policy.
static bool isFunctionOrMethod(const Decl *D)
isFunctionOrMethod - Return true if the given decl has function type (function or function-typed vari...
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
std::string getAsString(const LangOptions &LO) const
The template argument is a type.
static bool FindTagMember(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)
Base-class lookup callback that determines whether there exists a tag with the given name...
The template argument is actually a parameter pack.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
Represents a base class of a C++ class.
const FileEntry * getModuleHeaderToIncludeForDiagnostics(SourceLocation IncLoc, SourceLocation MLoc)
We want to produce a diagnostic at location IncLoc concerning a missing module import.
This is a scope that can contain a declaration.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
A template argument list.
void mergeDefinitionIntoModule(NamedDecl *ND, Module *M, bool NotifyListeners=true)
Note that the definition ND has been merged into module M, and should be visible whenever M is visibl...
SourceRange getCorrectionRange() const
const Type * getClass() const
static bool isNamespaceOrTranslationUnitScope(Scope *S)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
Represents a C++ struct/union/class.
The template argument is a template name that was provided for a template template parameter...
Look up a friend of a local class.
bool needsImplicitDefaultConstructor() const
Determine if we need to declare a default constructor for this class.
void addAllDecls(const LookupResult &Other)
Add all the declarations from another set of lookup results.
ObjCIvarDecl - Represents an ObjC instance variable.
Provides information a specialization of a member of a class template, which may be a member function...
base_class_iterator bases_end()
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
void setCorrectionRange(CXXScopeSpec *SS, const DeclarationNameInfo &TypoName)
void print(raw_ostream &)
AccessResult CheckMemberAccess(SourceLocation UseLoc, CXXRecordDecl *NamingClass, DeclAccessPair Found)
Checks access to a member.
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
TypoExpr * CorrectTypoDelayed(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, TypoDiagnosticGenerator TDG, TypoRecoveryCallback TRC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
static bool isPreferredLookupResult(Sema &S, Sema::LookupNameKind Kind, NamedDecl *D, NamedDecl *Existing)
Determine whether D is a better lookup result than Existing, given that they declare the same entity...
bool needsImplicitCopyConstructor() const
Determine whether this class needs an implicit copy constructor to be lazily declared.
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
void addNamespaces(const llvm::MapVector< NamespaceDecl *, bool > &KnownNamespaces)
Set-up method to add to the consumer the set of namespaces to use in performing corrections to nested...
virtual ~VisibleDeclConsumer()
Destroys the visible declaration consumer.
conversion_iterator conversion_begin() const
static void addAssociatedClassesAndNamespaces(AssociatedLookup &Result, QualType T)
bool isSet() const
Deprecated.
CXXMethodDecl * DeclareImplicitCopyAssignment(CXXRecordDecl *ClassDecl)
Declare the implicit copy assignment operator for the given class.
CXXConstructorDecl * LookupDefaultConstructor(CXXRecordDecl *Class)
Look up the default constructor for the given class.
DeclContext * getPrimaryContext()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
No viable function found.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
static std::pair< DeclContext *, bool > findOuterContext(Scope *S)
An l-value expression is a reference to an object with independent storage.
bool setUseQualifiedLookup(bool use=true)
A trivial tuple used to represent a source range.
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
NamedDecl - This represents a decl with a name.
void AddMethodCandidate(DeclAccessPair FoundDecl, QualType ObjectType, Expr::Classification ObjectClassification, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversion=false)
AddMethodCandidate - Adds a named decl (which is some kind of method) as a method candidate to the gi...
Represents C++ using-directive.
Look up of an operator name (e.g., operator+) for use with operator overloading.
static bool CppNamespaceLookup(Sema &S, LookupResult &R, ASTContext &Context, DeclContext *NS, UnqualUsingDirectiveSet &UDirs)
The global specifier '::'. There is no stored value.
bool requiresImport() const
Returns whether this typo correction is correcting to a declaration that was declared in a module tha...
static bool LookupDirect(Sema &S, LookupResult &R, const DeclContext *DC)
void WillReplaceSpecifier(bool ForceReplacement)
bool WantFunctionLikeCasts
The lookup resulted in an error.
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
ExceptionSpecInfo ExceptionSpec
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
iterator - Iterate over the decls of a specified declaration name.
void setFindLocalExtern(bool FindLocalExtern)
std::list< CXXBasePath >::iterator paths_iterator
IdentifierInfoLookup * getExternalIdentifierLookup() const
Retrieve the external identifier lookup object, if any.
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
static bool isCandidateViable(CorrectionCandidateCallback &CCC, TypoCorrection &Candidate)
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
bool isHidden() const
Determine whether this declaration is hidden from name lookup.
static bool isVisible(Sema &SemaRef, NamedDecl *D)
Determine whether the given declaration is visible to the program.
void ActOnPragmaDump(Scope *S, SourceLocation Loc, IdentifierInfo *II)
Called on #pragma clang __debug dump II.
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.