A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://clang.llvm.org/doxygen/HeuristicResolver_8cpp_source.html below:

clang: lib/Sema/HeuristicResolver.cpp Source File

27class

HeuristicResolverImpl {

29

HeuristicResolverImpl(ASTContext &Ctx) : Ctx(Ctx) {}

33

std::vector<const NamedDecl *>

34

resolveMemberExpr(

const

CXXDependentScopeMemberExpr *ME);

35

std::vector<const NamedDecl *>

36

resolveDeclRefExpr(

const

DependentScopeDeclRefExpr *RE);

37

std::vector<const NamedDecl *> resolveTypeOfCallExpr(

const

CallExpr *CE);

38

std::vector<const NamedDecl *> resolveCalleeOfCallExpr(

const

CallExpr *CE);

39

std::vector<const NamedDecl *>

40

resolveUsingValueDecl(

const

UnresolvedUsingValueDecl *UUVD);

41

std::vector<const NamedDecl *>

42

resolveDependentNameType(

const

DependentNameType *DNT);

43

std::vector<const NamedDecl *> resolveTemplateSpecializationType(

44 const

DependentTemplateSpecializationType *DTST);

45

QualType resolveNestedNameSpecifierToType(

const

NestedNameSpecifier *NNS);

52

llvm::SmallSet<const DependentNameType *, 4> SeenDependentNameTypes;

63

std::vector<const NamedDecl *>

64

resolveDependentMember(QualType

T

, DeclarationName Name,

65

llvm::function_ref<

bool

(

const

NamedDecl *ND)> Filter);

69

QualType resolveExprToType(

const

Expr *

E

);

70

std::vector<const NamedDecl *> resolveExprToDecls(

const

Expr *

E

);

75

TagDecl *resolveTypeToTagDecl(

const

Type *

T

);

84

QualType simplifyType(QualType Type,

const

Expr *

E

,

bool

UnwrapPointer);

93

std::vector<const NamedDecl *>

94

lookupDependentName(CXXRecordDecl *RD, DeclarationName Name,

95

llvm::function_ref<

bool

(

const

NamedDecl *ND)> Filter);

98

DeclarationName Name);

103const auto

NoFilter = [](

const

NamedDecl *

D

) {

return true

; };

104const auto

NonStaticFilter = [](

const

NamedDecl *

D

) {

105 return D

->isCXXInstanceMember();

107const auto

StaticFilter = [](

const

NamedDecl *

D

) {

108 return

!

D

->isCXXInstanceMember();

110const auto

ValueFilter = [](

const

NamedDecl *

D

) {

return

isa<ValueDecl>(

D

); };

111const auto

TypeFilter = [](

const

NamedDecl *

D

) {

return

isa<TypeDecl>(

D

); };

112const auto

TemplateFilter = [](

const

NamedDecl *

D

) {

113 return

isa<TemplateDecl>(

D

);

116

QualType resolveDeclsToType(

const

std::vector<const NamedDecl *> &Decls,

118 if

(Decls.size() != 1)

120 if

(

const auto

*TD = dyn_cast<TypeDecl>(Decls[0])) {

123 if

(

const auto

*VD = dyn_cast<ValueDecl>(Decls[0])) {

124 return

VD->getType();

129

TemplateName getReferencedTemplateName(

const

Type *

T

) {

130 if

(

const auto

*TST =

T

->

getAs

<TemplateSpecializationType>()) {

131 return

TST->getTemplateName();

133 if

(

const auto

*DTST =

T

->

getAs

<DeducedTemplateSpecializationType>()) {

134 return

DTST->getTemplateName();

136 return

TemplateName();

142

TagDecl *HeuristicResolverImpl::resolveTypeToTagDecl(

const

Type *

T

) {

148 if

(

const auto

*DNT =

T

->

getAs

<DependentNameType>()) {

149 T

= resolveDeclsToType(resolveDependentNameType(DNT), Ctx)

156 if

(

auto

*TT =

T

->

getAs

<TagType>()) {

157 return

TT->getDecl();

160 if

(

const auto

*ICNT =

T

->

getAs

<InjectedClassNameType>())

161 T

= ICNT->getInjectedSpecializationType().getTypePtrOrNull();

165

TemplateName TN = getReferencedTemplateName(

T

);

169 const

ClassTemplateDecl *TD =

170

dyn_cast_or_null<ClassTemplateDecl>(TN.getAsTemplateDecl());

174 return

TD->getTemplatedDecl();

177

QualType HeuristicResolverImpl::getPointeeType(QualType

T

) {

188 auto

ArrowOps = resolveDependentMember(

190 if

(ArrowOps.empty())

199 auto

*TST =

T

->

getAs

<TemplateSpecializationType>();

202 if

(TST->template_arguments().size() == 0)

204 const

TemplateArgument &FirstArg = TST->template_arguments()[0];

207 return

FirstArg.getAsType();

210

QualType HeuristicResolverImpl::simplifyType(QualType Type,

const

Expr *

E

,

211 bool

UnwrapPointer) {

212 bool

DidUnwrapPointer =

false

;

213 auto

SimplifyOneStep = [&](QualType

T

) {

216

DidUnwrapPointer =

true

;

220 if

(

const auto

*RT =

T

->

getAs

<ReferenceType>()) {

222 return

RT->getPointeeType();

224 if

(

const auto

*BT =

T

->

getAs

<BuiltinType>()) {

228 if

(

E

&& BT->getKind() == BuiltinType::Dependent) {

229 return

resolveExprToType(

E

);

239 if

(

E

&& AT->isUndeducedAutoType()) {

240 if

(

const auto

*DRE = dyn_cast<DeclRefExpr>(

E

)) {

241 if

(

const auto

*VD = dyn_cast<VarDecl>(DRE->getDecl())) {

243 return

resolveExprToType(VD->getInit());

250 while

(!

Type

.isNull()) {

251

QualType New = SimplifyOneStep(Type);

256 if

(UnwrapPointer && !DidUnwrapPointer)

261

std::vector<const NamedDecl *> HeuristicResolverImpl::resolveMemberExpr(

262 const

CXXDependentScopeMemberExpr *ME) {

274 if

(NestedNameSpecifier *NNS = ME->getQualifier()) {

275 if

(QualType QualifierType = resolveNestedNameSpecifierToType(NNS);

276

!QualifierType.isNull()) {

278

resolveDependentMember(QualifierType, ME->getMember(), NoFilter);

291

Expr *

Base

= ME->isImplicitAccess() ? nullptr : ME->getBase();

292

QualType BaseType = ME->getBaseType();

293

BaseType = simplifyType(BaseType,

Base

, ME->isArrow());

294 return

resolveDependentMember(BaseType, ME->getMember(), NoFilter);

297

std::vector<const NamedDecl *>

298

HeuristicResolverImpl::resolveDeclRefExpr(

const

DependentScopeDeclRefExpr *RE) {

299 return

resolveDependentMember(

300

resolveNestedNameSpecifierToType(RE->getQualifier()), RE->getDeclName(),

304

std::vector<const NamedDecl *>

305

HeuristicResolverImpl::resolveTypeOfCallExpr(

const

CallExpr *CE) {

306

QualType CalleeType = resolveExprToType(CE->getCallee());

307 if

(CalleeType.isNull())

309 if

(

const auto

*FnTypePtr = CalleeType->getAs<PointerType>())

310

CalleeType = FnTypePtr->getPointeeType();

311 if

(

const

FunctionType *FnType = CalleeType->getAs<FunctionType>()) {

312 if

(

const auto

*

D

=

313

resolveTypeToTagDecl(FnType->getReturnType().getTypePtr())) {

320

std::vector<const NamedDecl *>

321

HeuristicResolverImpl::resolveCalleeOfCallExpr(

const

CallExpr *CE) {

322 if

(

const auto

*ND = dyn_cast_or_null<NamedDecl>(CE->getCalleeDecl())) {

326 return

resolveExprToDecls(CE->getCallee());

329

std::vector<const NamedDecl *> HeuristicResolverImpl::resolveUsingValueDecl(

330 const

UnresolvedUsingValueDecl *UUVD) {

331 return

resolveDependentMember(QualType(UUVD->getQualifier()->getAsType(), 0),

332

UUVD->getNameInfo().getName(), ValueFilter);

335

std::vector<const NamedDecl *>

336

HeuristicResolverImpl::resolveDependentNameType(

const

DependentNameType *DNT) {

337 if

(

auto

[_, inserted] = SeenDependentNameTypes.insert(DNT); !inserted)

339 return

resolveDependentMember(

340

resolveNestedNameSpecifierToType(DNT->getQualifier()),

341

DNT->getIdentifier(), TypeFilter);

344

std::vector<const NamedDecl *>

345

HeuristicResolverImpl::resolveTemplateSpecializationType(

346 const

DependentTemplateSpecializationType *DTST) {

347 return

resolveDependentMember(

348

resolveNestedNameSpecifierToType(DTST->getQualifier()),

349

DTST->getIdentifier(), TemplateFilter);

352

std::vector<const NamedDecl *>

353

HeuristicResolverImpl::resolveExprToDecls(

const

Expr *

E

) {

354 if

(

const auto

*ME = dyn_cast<CXXDependentScopeMemberExpr>(

E

)) {

355 return

resolveMemberExpr(ME);

357 if

(

const auto

*RE = dyn_cast<DependentScopeDeclRefExpr>(

E

)) {

358 return

resolveDeclRefExpr(RE);

360 if

(

const auto

*OE = dyn_cast<OverloadExpr>(

E

)) {

361 return

{OE->decls_begin(), OE->decls_end()};

363 if

(

const auto

*CE = dyn_cast<CallExpr>(

E

)) {

364 return

resolveTypeOfCallExpr(CE);

366 if

(

const auto

*ME = dyn_cast<MemberExpr>(

E

))

367 return

{ME->getMemberDecl()};

372

QualType HeuristicResolverImpl::resolveExprToType(

const

Expr *

E

) {

373

std::vector<const NamedDecl *> Decls = resolveExprToDecls(

E

);

375 return

resolveDeclsToType(Decls, Ctx);

380

QualType HeuristicResolverImpl::resolveNestedNameSpecifierToType(

381 const

NestedNameSpecifier *NNS) {

389 switch

(NNS->getKind()) {

392 return

QualType(NNS->getAsType(), 0);

394 return

resolveDeclsToType(

395

resolveDependentMember(

396

resolveNestedNameSpecifierToType(NNS->getPrefix()),

397

NNS->getAsIdentifier(), TypeFilter),

412

DeclarationName Name) {

413 Path

.Decls = RD->lookup(Name).begin();

421bool

HeuristicResolverImpl::findOrdinaryMemberInDependentClasses(

423

DeclarationName Name) {

424

TagDecl *TD = resolveTypeToTagDecl(

Specifier

->getType().getTypePtr());

425 if

(

const auto

*RD = dyn_cast_if_present<CXXRecordDecl>(TD)) {

431

std::vector<const NamedDecl *> HeuristicResolverImpl::lookupDependentName(

432

CXXRecordDecl *RD, DeclarationName Name,

433

llvm::function_ref<

bool

(

const

NamedDecl *ND)> Filter) {

434

std::vector<const NamedDecl *> Results;

437 bool

AnyOrdinaryMembers =

false

;

438 for

(

const

NamedDecl *ND : RD->lookup(Name)) {

440

AnyOrdinaryMembers =

true

;

442

Results.push_back(ND);

444 if

(AnyOrdinaryMembers)

450 if

(!RD->lookupInBases(

451

[&](

const

CXXBaseSpecifier *

Specifier

, CXXBasePath &

Path

) {

452

return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);

459

Results.push_back(*I);

464

std::vector<const NamedDecl *> HeuristicResolverImpl::resolveDependentMember(

465

QualType QT, DeclarationName Name,

466

llvm::function_ref<

bool

(

const

NamedDecl *ND)> Filter) {

467 const Type

*

T

= QT.getTypePtrOrNull();

470

TagDecl *TD = resolveTypeToTagDecl(

T

);

473 if

(

auto

*ED = dyn_cast<EnumDecl>(TD)) {

474 auto Result

= ED->lookup(Name);

477 if

(

auto

*RD = dyn_cast<CXXRecordDecl>(TD)) {

478 if

(!RD->hasDefinition())

480

RD = RD->getDefinition();

481 return

lookupDependentName(RD, Name, [&](

const

NamedDecl *ND) {

484 if

(

const auto

*MD = dyn_cast<CXXMethodDecl>(ND)) {

485 return

!MD->isInstance() ||

486

MD->getMethodQualifiers().compatiblyIncludes(QT.getQualifiers(),

498 return

HeuristicResolverImpl(Ctx).resolveMemberExpr(ME);

502 return

HeuristicResolverImpl(Ctx).resolveDeclRefExpr(RE);

504

std::vector<const NamedDecl *>

506 return

HeuristicResolverImpl(Ctx).resolveTypeOfCallExpr(CE);

508

std::vector<const NamedDecl *>

510 return

HeuristicResolverImpl(Ctx).resolveCalleeOfCallExpr(CE);

514 return

HeuristicResolverImpl(Ctx).resolveUsingValueDecl(UUVD);

518 return

HeuristicResolverImpl(Ctx).resolveDependentNameType(DNT);

520

std::vector<const NamedDecl *>

523 return

HeuristicResolverImpl(Ctx).resolveTemplateSpecializationType(DTST);

527 return

HeuristicResolverImpl(Ctx).resolveNestedNameSpecifierToType(NNS);

530 return

HeuristicResolverImpl(Ctx).getPointeeType(

T

);

Defines the clang::ASTContext interface.

static bool findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, DeclarationName Name)

static bool isOrdinaryMember(const NamedDecl *ND)

static bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path, DeclarationName Name)

Defines the C++ template declaration subclasses.

Defines the clang::Expr interface and subclasses for C++ expressions.

static QualType getPointeeType(const MemRegion *R)

C Language Family Type Representation.

const NestedNameSpecifier * Specifier

DeclarationNameTable DeclarationNames

QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const

Return the unique reference to the type for the specified type declaration.

Represents a C++ member access expression where the actual member referenced could not be resolved be...

CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).

lookup_result::iterator lookup_iterator

@ IDNS_Ordinary

Ordinary names.

@ IDNS_Member

Members, declared with object declarations within tag definitions.

@ IDNS_Tag

Tags, declared with 'struct foo;' and referenced with 'struct foo'.

Represents a qualified type name for which the type name is dependent.

A qualified reference to a name whose declaration cannot yet be resolved.

Represents a template specialization type whose template cannot be resolved, e.g.

std::vector< const NamedDecl * > resolveDeclRefExpr(const DependentScopeDeclRefExpr *RE) const

const QualType getPointeeType(QualType T) const

std::vector< const NamedDecl * > resolveMemberExpr(const CXXDependentScopeMemberExpr *ME) const

QualType resolveNestedNameSpecifierToType(const NestedNameSpecifier *NNS) const

std::vector< const NamedDecl * > resolveCalleeOfCallExpr(const CallExpr *CE) const

std::vector< const NamedDecl * > resolveTypeOfCallExpr(const CallExpr *CE) const

std::vector< const NamedDecl * > resolveUsingValueDecl(const UnresolvedUsingValueDecl *UUVD) const

std::vector< const NamedDecl * > resolveTemplateSpecializationType(const DependentTemplateSpecializationType *DTST) const

std::vector< const NamedDecl * > resolveDependentNameType(const DependentNameType *DNT) const

Represents a C++ nested name specifier, such as "\::std::vector<int>::".

@ TypeSpec

A type, stored as a Type*.

@ TypeSpecWithTemplate

A type that was preceded by the 'template' keyword, stored as a Type*.

@ Identifier

An identifier, stored as an IdentifierInfo*.

A (possibly-)qualified type.

bool isNull() const

Return true if this QualType doesn't point to a type yet.

const Type * getTypePtr() const

Retrieves a pointer to the underlying (unqualified) type.

@ Type

The template argument is a type.

bool isPointerType() const

const T * castAs() const

Member-template castAs<specific type>.

AutoType * getContainedAutoType() const

Get the AutoType whose type will be deduced for a variable with an initializer of this type.

QualType getCanonicalTypeInternal() const

const T * getAs() const

Member-template getAs<specific type>'.

Represents a dependent using declaration which was not marked with typename.

The JSON file list parser is used to communicate input to InstallAPI.

@ Result

The result type of a method or function.

const FunctionProtoType * T


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4