clang: lib/Analysis/BodyFarm.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

25#include "llvm/ADT/StringSwitch.h"

26#include "llvm/Support/Debug.h"

27#include

28

29#define DEBUG_TYPE "body-farm"

30

31using namespace clang;

32

33

34

35

36

38

40 if (!BPT)

41 return false;

42

43

44

48}

49

50namespace {

51class ASTMaker {

52public:

53 ASTMaker(ASTContext &C) : C(C) {}

54

55

56 BinaryOperator *makeAssignment(const Expr *LHS, const Expr *RHS, QualType Ty);

57

58

59 BinaryOperator *makeComparison(const Expr *LHS, const Expr *RHS,

61

62

64

65

66 DeclRefExpr *makeDeclRefExpr(const VarDecl *D,

67 bool RefersToEnclosingVariableOrCapture = false);

68

69

70 UnaryOperator *makeDereference(const Expr *Arg, QualType Ty);

71

72

73 Expr *makeIntegralCast(const Expr *Arg, QualType Ty);

74

75

76 ImplicitCastExpr *makeIntegralCastToBoolean(const Expr *Arg);

77

78

79 ImplicitCastExpr *makeLvalueToRvalue(const Expr *Arg, QualType Ty);

80

81

82

83 ImplicitCastExpr *

84 makeLvalueToRvalue(const VarDecl *Decl,

85 bool RefersToEnclosingVariableOrCapture = false);

86

87

88 ImplicitCastExpr *makeImplicitCast(const Expr *Arg, QualType Ty,

89 CastKind CK = CK_LValueToRValue);

90

91

92 CastExpr *makeReferenceCast(const Expr *Arg, QualType Ty);

93

94

95 ObjCBoolLiteralExpr *makeObjCBool(bool Val);

96

97

98 ObjCIvarRefExpr *makeObjCIvarRef(const Expr *Base, const ObjCIvarDecl *IVar);

99

100

101 ReturnStmt *makeReturn(const Expr *RetVal);

102

103

104 IntegerLiteral *makeIntegerLiteral(uint64_t Value, QualType Ty);

105

106

107 MemberExpr *makeMemberExpression(Expr *base, ValueDecl *MemberDecl,

108 bool IsArrow = false,

110

111

112

113 ValueDecl *findMemberField(const RecordDecl *RD, StringRef Name);

114

115private:

116 ASTContext &C;

117};

118}

119

123 C, const_cast<Expr *>(LHS), const_cast<Expr *>(RHS), BO_Assign, Ty,

125}

126

127BinaryOperator *ASTMaker::makeComparison(const Expr *LHS, const Expr *RHS,

132 C, const_cast<Expr *>(LHS), const_cast<Expr *>(RHS), Op,

134 FPOptionsOverride());

135}

136

137CompoundStmt *ASTMaker::makeCompound(ArrayRef<Stmt *> Stmts) {

139 SourceLocation());

140}

141

142DeclRefExpr *ASTMaker::makeDeclRefExpr(

143 const VarDecl *D,

144 bool RefersToEnclosingVariableOrCapture) {

146

148 C, NestedNameSpecifierLoc(), SourceLocation(), const_cast<VarDecl *>(D),

149 RefersToEnclosingVariableOrCapture, SourceLocation(), Type, VK_LValue);

150 return DR;

151}

152

153UnaryOperator *ASTMaker::makeDereference(const Expr *Arg, QualType Ty) {

156 false, FPOptionsOverride());

157}

158

159ImplicitCastExpr *ASTMaker::makeLvalueToRvalue(const Expr *Arg, QualType Ty) {

160 return makeImplicitCast(Arg, Ty, CK_LValueToRValue);

161}

162

163ImplicitCastExpr *

164ASTMaker::makeLvalueToRvalue(const VarDecl *Arg,

165 bool RefersToEnclosingVariableOrCapture) {

167 return makeLvalueToRvalue(makeDeclRefExpr(Arg,

168 RefersToEnclosingVariableOrCapture),

170}

171

172ImplicitCastExpr *ASTMaker::makeImplicitCast(const Expr *Arg, QualType Ty,

175 CK,

176 const_cast<Expr *>(Arg),

177 nullptr,

179 FPOptionsOverride());

180}

181

182CastExpr *ASTMaker::makeReferenceCast(const Expr *Arg, QualType Ty) {

187 const_cast<Expr *>(Arg), nullptr,

188 C.getTrivialTypeSourceInfo(Ty), FPOptionsOverride(),

189 SourceLocation(), SourceLocation(), SourceRange());

190}

191

192Expr *ASTMaker::makeIntegralCast(const Expr *Arg, QualType Ty) {

193 if (Arg->getType() == Ty)

194 return const_cast<Expr*>(Arg);

195 return makeImplicitCast(Arg, Ty, CK_IntegralCast);

196}

197

198ImplicitCastExpr *ASTMaker::makeIntegralCastToBoolean(const Expr *Arg) {

199 return makeImplicitCast(Arg, C.BoolTy, CK_IntegralToBoolean);

200}

201

202ObjCBoolLiteralExpr *ASTMaker::makeObjCBool(bool Val) {

203 QualType Ty = C.getBOOLDecl() ? C.getBOOLType() : C.ObjCBuiltinBoolTy;

204 return new (C) ObjCBoolLiteralExpr(Val, Ty, SourceLocation());

205}

206

207ObjCIvarRefExpr *ASTMaker::makeObjCIvarRef(const Expr *Base,

208 const ObjCIvarDecl *IVar) {

209 return new (C) ObjCIvarRefExpr(const_cast<ObjCIvarDecl*>(IVar),

210 IVar->getType(), SourceLocation(),

211 SourceLocation(), const_cast<Expr*>(Base),

212 true, false);

213}

214

215ReturnStmt *ASTMaker::makeReturn(const Expr *RetVal) {

216 return ReturnStmt::Create(C, SourceLocation(), const_cast<Expr *>(RetVal),

217 nullptr);

218}

219

220IntegerLiteral *ASTMaker::makeIntegerLiteral(uint64_t Value, QualType Ty) {

221 llvm::APInt APValue = llvm::APInt(C.getTypeSize(Ty), Value);

223}

224

225MemberExpr *ASTMaker::makeMemberExpression(Expr *base, ValueDecl *MemberDecl,

226 bool IsArrow,

228

231 C, base, IsArrow, SourceLocation(), NestedNameSpecifierLoc(),

232 SourceLocation(), MemberDecl, FoundDecl,

233 DeclarationNameInfo(MemberDecl->getDeclName(), SourceLocation()),

234 nullptr, MemberDecl->getType(), ValueKind,

236}

237

238ValueDecl *ASTMaker::findMemberField(const RecordDecl *RD, StringRef Name) {

239

240 CXXBasePaths Paths(

241 false,

242 false,

243 false);

244 const IdentifierInfo &II = C.Idents.get(Name);

245 DeclarationName DeclName = C.DeclarationNames.getIdentifier(&II);

246

247 DeclContextLookupResult Decls = RD->lookup(DeclName);

248 for (NamedDecl *FoundDecl : Decls)

251

252 return nullptr;

253}

254

255

256

257

258

260

264

265 QualType Ty = Callback->getType();

267 Expr *SubExpr;

269 SubExpr = M.makeImplicitCast(

272 Call->getType()->isFunctionType()) {

274 SubExpr = M.makeImplicitCast(Call, Ty, CK_FunctionToPointerDecay);

276 && Call->getType()->isPointerType()

277 && Call->getType()->getPointeeType()->isFunctionType()){

278 SubExpr = Call;

279 } else {

280 llvm_unreachable("Unexpected state");

281 }

282

285}

286

291 assert(CallbackDecl != nullptr);

292 assert(CallbackDecl->isLambda());

294 assert(callOperatorDecl != nullptr);

295

297 C,

299 SourceLocation(), callOperatorDecl,

300 false,

302 callOperatorDecl->getType(),

304

306 C, OO_Call, callOperatorDeclRef,

307 CallArgs,

308 C.VoidTy,

312}

313

314

315

316

317

318

320 LLVM_DEBUG(llvm::dbgs() << "Generating body for std::move / std::forward\n");

321

322 ASTMaker M(C);

323

326 Expr *Cast = M.makeReferenceCast(Param, ReturnType);

327 return M.makeReturn(Cast);

328}

329

330

331

332

333

334

335

336

337

338

339

340

341

342

343

344

346 LLVM_DEBUG(llvm::dbgs() << "Generating body for call_once\n");

347

348

350 return nullptr;

351

352 ASTMaker M(C);

353

356

357 if (!Callback->getType()->isReferenceType()) {

358 llvm::dbgs() << "libcxx03 std::call_once implementation, skipping.\n";

359 return nullptr;

360 }

362 llvm::dbgs() << "unknown std::call_once implementation, skipping.\n";

363 return nullptr;

364 }

365

366 QualType CallbackType = Callback->getType().getNonReferenceType();

367

368

372

373 if (!FlagRecordDecl) {

374 LLVM_DEBUG(llvm::dbgs() << "Flag field is not a record: "

375 << "unknown std::call_once implementation, "

376 << "ignoring the call.\n");

377 return nullptr;

378 }

379

380

381

382 ValueDecl *FlagFieldDecl = M.findMemberField(FlagRecordDecl, "__state_");

383

384

385

386 if (!FlagFieldDecl) {

387 FlagFieldDecl = M.findMemberField(FlagRecordDecl, "_M_once");

388 }

389

390 if (!FlagFieldDecl) {

391 LLVM_DEBUG(llvm::dbgs() << "No field _M_once or __state_ found on "

392 << "std::once_flag struct: unknown std::call_once "

393 << "implementation, ignoring the call.");

394 return nullptr;

395 }

396

397 bool isLambdaCall = CallbackRecordDecl && CallbackRecordDecl->isLambda();

398 if (CallbackRecordDecl && !isLambdaCall) {

399 LLVM_DEBUG(llvm::dbgs()

400 << "Not supported: synthesizing body for functors when "

401 << "body farming std::call_once, ignoring the call.");

402 return nullptr;

403 }

404

407 if (isLambdaCall) {

408

409

410 CallArgs.push_back(

411 M.makeDeclRefExpr(Callback,

412 true));

417 CallbackFunctionType =

419 } else {

421 }

422

423 if (!CallbackFunctionType)

424 return nullptr;

425

426

428 LLVM_DEBUG(llvm::dbgs() << "Types of params of the callback do not match "

429 << "params passed to std::call_once, "

430 << "ignoring the call\n");

431 return nullptr;

432 }

433

434

435

436

439 assert(PDecl);

444 LLVM_DEBUG(llvm::dbgs() << "Types of params of the callback do not match "

445 << "params passed to std::call_once, "

446 << "ignoring the call\n");

447 return nullptr;

448 }

449 Expr *ParamExpr = M.makeDeclRefExpr(PDecl);

452 ParamExpr = M.makeLvalueToRvalue(ParamExpr, PTy);

453 }

454 CallArgs.push_back(ParamExpr);

455 }

456

458 if (isLambdaCall) {

459

461 CallbackRecordDecl, CallArgs);

462 } else {

463

464

466 }

467

469 M.makeDeclRefExpr(Flag,

470 true);

471

472

473 MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FlagFieldDecl);

474 assert(Deref->isLValue());

475 QualType DerefType = Deref->getType();

476

477

479 C,

480

481 M.makeImplicitCast(M.makeLvalueToRvalue(Deref, DerefType), DerefType,

482 CK_IntegralToBoolean),

483 UO_LNot,

484 C.IntTy,

488

489

491 Deref, M.makeIntegralCast(M.makeIntegerLiteral(1, C.IntTy), DerefType),

492 DerefType);

493

494 auto *Out =

496 nullptr,

497 nullptr,

498 FlagCheck,

501 M.makeCompound({CallbackCall, FlagAssignment}));

502

503 return Out;

504}

505

506

508

510 return nullptr;

511

512

516 if (!PredicatePtrTy)

517 return nullptr;

520 return nullptr;

521

522

526 return nullptr;

527

528

529

530

531

532

533

534

535

536

537

538 ASTMaker M(C);

539

540

542 C,

543 M.makeLvalueToRvalue(Block),

544 {},

545 C.VoidTy,

548

549

550 Expr *DoneValue =

554

556 M.makeAssignment(

557 M.makeDereference(

558 M.makeLvalueToRvalue(

559 M.makeDeclRefExpr(Predicate), PredicateQPtrTy),

560 PredicateTy),

561 M.makeIntegralCast(DoneValue, PredicateTy),

562 PredicateTy);

563

564

565 Stmt *Stmts[] = { B, CE };

567

568

570 M.makeLvalueToRvalue(

571 M.makeDereference(

572 M.makeLvalueToRvalue(

573 M.makeDeclRefExpr(Predicate),

574 PredicateQPtrTy),

575 PredicateTy),

576 PredicateTy);

577

578 Expr *GuardCondition = M.makeComparison(LValToRval, DoneValue, BO_NE);

579

581 nullptr,

582 nullptr,

583 GuardCondition,

586 CS);

587 return If;

588}

589

590

592

594 return nullptr;

595

596

600 return nullptr;

601

602

603

604

605

606

607

608

609 ASTMaker M(C);

614 return CE;

615}

616

618{

619

621 return nullptr;

622

623

624

625

626

627

628

629

630

631

632

633

637 return nullptr;

638

641

644

645 assert(OldValueTy == NewValueTy);

646

650 if (!PT)

651 return nullptr;

653

654 ASTMaker M(C);

655

657 M.makeComparison(

658 M.makeLvalueToRvalue(M.makeDeclRefExpr(OldValue), OldValueTy),

659 M.makeLvalueToRvalue(

660 M.makeDereference(

661 M.makeLvalueToRvalue(M.makeDeclRefExpr(TheValue), TheValueTy),

662 PointeeTy),

663 PointeeTy),

664 BO_EQ);

665

666

667 Stmt *Stmts[2];

668 Stmts[0] =

669 M.makeAssignment(

670 M.makeDereference(

671 M.makeLvalueToRvalue(M.makeDeclRefExpr(TheValue), TheValueTy),

672 PointeeTy),

673 M.makeLvalueToRvalue(M.makeDeclRefExpr(NewValue), NewValueTy),

674 NewValueTy);

675

676 Expr *BoolVal = M.makeObjCBool(true);

677 Expr *RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)

678 : M.makeIntegralCast(BoolVal, ResultTy);

679 Stmts[1] = M.makeReturn(RetVal);

681

682

683 BoolVal = M.makeObjCBool(false);

684 RetVal = isBoolean ? M.makeIntegralCastToBoolean(BoolVal)

685 : M.makeIntegralCast(BoolVal, ResultTy);

686 Stmt *Else = M.makeReturn(RetVal);

687

688

689 auto *If =

691 nullptr,

695

696 return If;

697}

698

700 std::optional<Stmt *> &Val = Bodies[D];

701 if (Val)

702 return *Val;

703

704 Val = nullptr;

705

707 return nullptr;

708

709 StringRef Name = D->getName();

710 if (Name.empty())

711 return nullptr;

712

714

715 if (unsigned BuiltinID = D->getBuiltinID()) {

716 switch (BuiltinID) {

717 case Builtin::BIas_const:

718 case Builtin::BIforward:

719 case Builtin::BIforward_like:

720 case Builtin::BImove:

721 case Builtin::BImove_if_noexcept:

723 break;

724 default:

725 FF = nullptr;

726 break;

727 }

728 } else if (Name.starts_with("OSAtomicCompareAndSwap") ||

729 Name.starts_with("objc_atomicCompareAndSwap")) {

733 } else {

734 FF = llvm::StringSwitch(Name)

737 .Default(nullptr);

738 }

739

740 if (FF) { Val = FF(C, D); }

741 else if (Injector) { Val = Injector->getBody(D); }

742 return *Val;

743}

744

747

748 if (IVar)

749 return IVar;

750

751

752

753

754

755

756

758 return nullptr;

759

762 if (auto *InterfaceDecl = dyn_cast(Container)) {

763 PrimaryInterface = InterfaceDecl;

764 } else if (auto *CategoryDecl = dyn_cast(Container)) {

765 PrimaryInterface = CategoryDecl->getClassInterface();

766 } else if (auto *ImplDecl = dyn_cast(Container)) {

767 PrimaryInterface = ImplDecl->getClassInterface();

768 } else {

769 return nullptr;

770 }

771

772

773

774

777 if (ShadowingProp && ShadowingProp != Prop) {

778 IVar = ShadowingProp->getPropertyIvarDecl();

779 }

780

781 return IVar;

782}

783

786

789

790

791

792

797 if (const ObjCPropertyDecl *Candidate = PI->getPropertyDecl()) {

798 if (Candidate->getGetterName() == MD->getSelector()) {

799 Prop = Candidate;

801 }

802 }

803 }

804 }

805

806 if (!IVar) {

809 }

810

811 if (!IVar || !Prop)

812 return nullptr;

813

814

816 return nullptr;

817

818

819

820

821

822

825 if (ImplDecl) {

827 if (I->getPropertyDecl() != Prop)

828 continue;

829

830 if (I->getGetterCXXConstructor()) {

831 ASTMaker M(Ctx);

832 return M.makeReturn(I->getGetterCXXConstructor());

833 }

834 }

835 }

836

837

838

841 return nullptr;

844 return nullptr;

845

846

847

848 ASTMaker M(Ctx);

849

851 if (!selfVar)

852 return nullptr;

853

854 Expr *loadedIVar = M.makeObjCIvarRef(

855 M.makeLvalueToRvalue(M.makeDeclRefExpr(selfVar), selfVar->getType()),

856 IVar);

857

859 loadedIVar = M.makeLvalueToRvalue(loadedIVar, IVar->getType());

860

861 return M.makeReturn(loadedIVar);

862}

863

865

867 return nullptr;

868

870

871

872

874 return nullptr;

875

876 std::optional<Stmt *> &Val = Bodies[D];

877 if (Val)

878 return *Val;

879 Val = nullptr;

880

881

882

883

884

885

886

887

888

889

891 return nullptr;

892

893

894

896 if (dyn_cast(D->getParent()) != OID)

898 auto *OMD = Ext->getInstanceMethod(D->getSelector());

899 if (OMD && !OMD->isImplicit())

900 return nullptr;

901 }

902

904

905 return *Val;

906}

Defines the clang::ASTContext interface.

static Stmt * create_call_once(ASTContext &C, const FunctionDecl *D)

Create a fake body for std::call_once.

Definition BodyFarm.cpp:345

static Stmt * create_dispatch_once(ASTContext &C, const FunctionDecl *D)

Create a fake body for dispatch_once.

Definition BodyFarm.cpp:507

static Stmt * create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D)

Definition BodyFarm.cpp:617

static Stmt * create_dispatch_sync(ASTContext &C, const FunctionDecl *D)

Create a fake body for dispatch_sync.

Definition BodyFarm.cpp:591

static Stmt * createObjCPropertyGetter(ASTContext &Ctx, const ObjCMethodDecl *MD)

Definition BodyFarm.cpp:784

static Stmt * create_std_move_forward(ASTContext &C, const FunctionDecl *D)

Create a fake body for 'std::move' or 'std::forward'.

Definition BodyFarm.cpp:319

static CallExpr * create_call_once_lambda_call(ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, CXXRecordDecl *CallbackDecl, ArrayRef< Expr * > CallArgs)

Definition BodyFarm.cpp:287

static CallExpr * create_call_once_funcptr_call(ASTContext &C, ASTMaker M, const ParmVarDecl *Callback, ArrayRef< Expr * > CallArgs)

Definition BodyFarm.cpp:261

static bool isDispatchBlock(QualType Ty)

Definition BodyFarm.cpp:37

Stmt *(* FunctionFarmer)(ASTContext &C, const FunctionDecl *D)

Definition BodyFarm.cpp:259

static const ObjCIvarDecl * findBackingIvar(const ObjCPropertyDecl *Prop)

Definition BodyFarm.cpp:745

Defines enum values for all the target-independent builtin functions.

Defines the clang::CodeInjector interface which is responsible for injecting AST of function definiti...

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

Defines an enumeration for C++ overloaded operators.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

static bool hasSameUnqualifiedType(QualType T1, QualType T2)

Determine whether the given types are equivalent after cvr-qualifiers have been removed.

A builtin binary operation expression such as "x + y" or "x <= y".

bool isComparisonOp() const

static BinaryOperator * Create(const ASTContext &C, Expr *lhs, Expr *rhs, Opcode opc, QualType ResTy, ExprValueKind VK, ExprObjectKind OK, SourceLocation opLoc, FPOptionsOverride FPFeatures)

BinaryOperatorKind Opcode

QualType getPointeeType() const

Stmt * getBody(const FunctionDecl *D)

Factory method for creating bodies for ordinary functions.

Definition BodyFarm.cpp:699

static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptionsOverride FPFeatures, ADLCallKind UsesADL=NotADL)

Represents a C++ struct/union/class.

bool isLambda() const

Determine whether this class describes a lambda function object.

CXXMethodDecl * getLambdaCallOperator() const

Retrieve the lambda call operator of the closure type if this is a closure type.

static CXXStaticCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind K, Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written, FPOptionsOverride FPO, SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets)

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

static CallExpr * Create(const ASTContext &Ctx, Expr *Fn, ArrayRef< Expr * > Args, QualType Ty, ExprValueKind VK, SourceLocation RParenLoc, FPOptionsOverride FPFeatures, unsigned MinNumArgs=0, ADLCallKind UsesADL=NotADL)

Create a call expression.

CompoundStmt - This represents a group of statements like { stmt stmt }.

static CompoundStmt * Create(const ASTContext &C, ArrayRef< Stmt * > Stmts, FPOptionsOverride FPFeatures, SourceLocation LB, SourceLocation RB)

static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)

DeclContext * getParent()

getParent - Returns the containing DeclContext.

lookup_result lookup(DeclarationName Name) const

lookup - Find the declarations (if any) with the given Name in this context.

bool isStdNamespace() const

bool isFunctionOrMethod() const

A reference to a declared variable, function, enum, etc.

static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr, NonOdrUseReason NOUR=NOUR_None)

bool isImplicit() const

isImplicit - Indicates whether the declaration was implicitly generated by the implementation.

DeclContext * getDeclContext()

This represents one expression.

Represents difference between two FPOptions values.

Represents a function declaration or definition.

const ParmVarDecl * getParamDecl(unsigned i) const

unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const

Returns a value indicating whether this function corresponds to a builtin function.

QualType getReturnType() const

unsigned getNumParams() const

Return the number of parameters this function must have based on its FunctionType.

size_t param_size() const

Represents a prototype with parameter type info, e.g.

unsigned getNumParams() const

QualType getParamType(unsigned i) const

FunctionType - C99 6.7.5.3 - Function Declarators.

QualType getReturnType() const

static IfStmt * Create(const ASTContext &Ctx, SourceLocation IL, IfStatementKind Kind, Stmt *Init, VarDecl *Var, Expr *Cond, SourceLocation LPL, SourceLocation RPL, Stmt *Then, SourceLocation EL=SourceLocation(), Stmt *Else=nullptr)

Create an IfStmt.

ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...

static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat, FPOptionsOverride FPO)

static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)

Returns a new integer literal with value 'V' and type 'type'.

MemberExpr - [C99 6.5.2.3] Structure and Union Members.

static MemberExpr * Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs, QualType T, ExprValueKind VK, ExprObjectKind OK, NonOdrUseReason NOUR)

IdentifierInfo * getIdentifier() const

Get the identifier that names this declaration, if there is one.

StringRef getName() const

Get the name of identifier for this declaration as a StringRef.

DeclarationName getDeclName() const

Get the actual, stored name of the declaration, which may be a special name.

A C++ nested-name-specifier augmented with source location information.

propimpl_range property_impls() const

ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...

Represents an ObjC class declaration.

ObjCPropertyDecl * FindPropertyVisibleInPrimaryClass(const IdentifierInfo *PropertyId, ObjCPropertyQueryKind QueryKind) const

FindPropertyVisibleInPrimaryClass - Finds declaration of the property with name 'PropertyId' in the p...

ObjCImplementationDecl * getImplementation() const

known_extensions_range known_extensions() const

ObjCIvarDecl - Represents an ObjC instance variable.

ObjCInterfaceDecl * getContainingInterface()

Return the class interface that this ivar is logically contained in; this is either the interface whe...

ObjCMethodDecl - Represents an instance or class method declaration.

ImplicitParamDecl * getSelfDecl() const

unsigned param_size() const

bool isPropertyAccessor() const

const ObjCPropertyDecl * findPropertyDecl(bool CheckOverrides=true) const

Returns the property associated with this method's selector.

ObjCMethodDecl * getCanonicalDecl() override

Retrieves the "canonical" declaration of the given declaration.

bool isSynthesizedAccessorStub() const

Selector getSelector() const

QualType getReturnType() const

ObjCInterfaceDecl * getClassInterface()

Represents one property declaration in an Objective-C interface.

ObjCPropertyQueryKind getQueryKind() const

bool isReadOnly() const

isReadOnly - Return true iff the property has a setter.

ObjCIvarDecl * getPropertyIvarDecl() const

ObjCPropertyAttribute::Kind getPropertyAttributes() const

A single parameter index whose accessors require each use to make explicit the parameter index encodi...

Represents a parameter to a function.

PointerType - C99 6.7.5.1 - Pointer Declarators.

QualType getPointeeType() const

A (possibly-)qualified type.

bool isTriviallyCopyableType(const ASTContext &Context) const

Return true if this is a trivially copyable type (C++0x [basic.types]p9)

bool isNull() const

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

QualType getNonReferenceType() const

If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...

QualType getCanonicalType() const

static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)

Create a return statement.

Encodes a location in the source.

Stmt - This represents one statement.

bool isBooleanType() const

bool isRValueReferenceType() const

CXXRecordDecl * getAsCXXRecordDecl() const

Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...

RecordDecl * getAsRecordDecl() const

Retrieves the RecordDecl this type refers to.

bool isIntegerType() const

isIntegerType() does not include complex integers (a GCC extension).

const T * castAs() const

Member-template castAs.

bool isReferenceType() const

bool isIntegralType(const ASTContext &Ctx) const

Determine whether this type is an integral type.

QualType getPointeeType() const

If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.

bool isLValueReferenceType() const

bool isObjCLifetimeType() const

Returns true if objects of this type have lifetime semantics under ARC.

const T * getAs() const

Member-template getAs'.

UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...

static UnaryOperator * Create(const ASTContext &C, Expr *input, Opcode opc, QualType type, ExprValueKind VK, ExprObjectKind OK, SourceLocation l, bool CanOverflow, FPOptionsOverride FPFeatures)

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

Represents a variable declaration or definition.

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

@ Comparison

A comparison.

@ OK_Ordinary

An ordinary object is located at an address in memory.

@ If

'if' clause, allowed on all the Compute Constructs, Data Constructs, Executable Constructs,...

@ Type

The name was classified as a type.

CastKind

CastKind - The kind of operation required for a conversion.

ExprValueKind

The categorization of expression values, currently following the C++11 scheme.

@ VK_PRValue

A pr-value expression (in the C++11 taxonomy) produces a temporary value.

@ VK_XValue

An x-value expression is a reference to an object with independent storage but which can be "moved",...

@ VK_LValue

An l-value expression is a reference to an object with independent storage.

U cast(CodeGen::Address addr)

@ NOUR_None

This is an odr-use.