*Current = &
E;
38 while(Current !=
Last) {
40 if(
auto*EWC = dyn_cast<ExprWithCleanups>(Current)) {
41Current = EWC->getSubExpr();
42assert(Current !=
nullptr);
44 if(
auto*CE = dyn_cast<ConstantExpr>(Current)) {
45Current = CE->getSubExpr();
46assert(Current !=
nullptr);
48Current = Current->IgnoreParens();
49assert(Current !=
nullptr);
55 if(
auto*
E= dyn_cast<Expr>(&S))
83 if(Fields.size() != FieldLocs.size())
85 for([[maybe_unused]]
auto[Field,
Loc] : FieldLocs)
86 if(!Fields.contains(cast_or_null<FieldDecl>(Field)))
95template<
classInitListT>
96staticstd::vector<const FieldDecl *>
98 const RecordDecl*RD = InitList->getType()->getAsRecordDecl();
99assert(RD !=
nullptr);
101std::vector<const FieldDecl *> Fields;
103 if(InitList->getType()->isUnionType()) {
104 if(
const FieldDecl*Field = InitList->getInitializedFieldInUnion())
105Fields.push_back(Field);
114RD->
fields(), std::back_inserter(Fields),
115[](
const FieldDecl*Field) { return !Field->isUnnamedBitField(); });
122InitList->inits()) {}
128ParenInitList->getInitExprs()) {}
131 QualTypeTy, std::vector<const FieldDecl *> Fields,
134assert(RD !=
nullptr);
142assert(Fields.size() <= 1);
143 if(!Fields.empty()) {
144ImplicitValueInitForUnion.emplace(Fields.front()->getType());
145InitsForUnion.push_back(&*ImplicitValueInitForUnion);
147Inits = InitsForUnion;
152assert(Fields.size() + RD->getNumBases() == Inits.size());
153 for(
constCXXBaseSpecifier &
Base: RD->bases()) {
154assert(InitIdx < Inits.size());
155Expr *
Init= Inits[InitIdx++];
156BaseInits.emplace_back(&
Base,
Init);
159assert(Fields.size() == Inits.size() - InitIdx);
160 for(
constFieldDecl *Field : Fields) {
161assert(InitIdx < Inits.size());
162Expr *
Init= Inits[InitIdx++];
163FieldInits.emplace_back(Field,
Init);
168llvm::DenseSet<const VarDecl *> &Globals) {
169 if(
auto*
V= dyn_cast<VarDecl>(&
D))
170 if(
V->hasGlobalStorage())
175llvm::DenseSet<const VarDecl *> &Locals) {
176 if(
auto*
V= dyn_cast<VarDecl>(&
D))
177 if(
V->hasLocalStorage() && !isa<ParmVarDecl>(
V))
182llvm::DenseSet<const FunctionDecl *> &Funcs) {
183 if(
auto*FD = dyn_cast<FunctionDecl>(&
D))
190 const auto*MethodDecl = dyn_cast_or_null<CXXMethodDecl>(
C.getCalleeDecl());
193 auto*Body = dyn_cast_or_null<CompoundStmt>(MethodDecl->getBody());
194 if(!Body || Body->size() != 1)
196 if(
auto*RS = dyn_cast<ReturnStmt>(*Body->body_begin()))
197 if(
auto*Return = RS->getRetValue())
198 returndyn_cast<MemberExpr>(Return->IgnoreParenImpCasts());
205: Referenced(Referenced) {}
209 if(
Init->isMemberInitializer()) {
210Referenced.
Fields.insert(
Init->getMember());
211}
else if(
Init->isIndirectMemberInitializer()) {
212 for(
const auto*I :
Init->getIndirectMember()->chain())
213Referenced.
Fields.insert(cast<FieldDecl>(I));
223 if(
auto*DefaultInit = dyn_cast<CXXDefaultInitExpr>(InitExpr))
246 if(
const auto*FD = dyn_cast<FieldDecl>(
E->getMemberDecl()))
247Referenced.
Fields.insert(FD);
256 if(
const auto*FD = dyn_cast<FieldDecl>(VD))
257Referenced.
Fields.insert(FD);
264Referenced.
Fields.insert(FD);
271Referenced.
Fields.insert(FD);
283 if(
const auto*CtorDecl = dyn_cast<CXXConstructorDecl>(&FD))
296 if(
const auto*Method = dyn_cast<CXXMethodDecl>(&FD);
298 for(
const auto&
Capture: Method->getParent()->captures()) {
299 if(
Capture.capturesVariable()) {
300 if(
const auto*Param =
301dyn_cast<ParmVarDecl>(
Capture.getCapturedVar())) {
302 Result.LambdaCapturedParams.insert(Param);
This file provides some common utility functions for processing Lambda related AST Constructs.
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the clang::Expr interface and subclasses for C++ expressions.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
C Language Family Type Representation.
Represents a base class of a C++ class.
Represents a C++ constructor within a class.
Represents a C++ base or member initializer.
Represents a call to a member function that may be written either with member call syntax (e....
Represents a list-initialization with parenthesis.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
virtual bool TraverseStmt(MaybeConst< Stmt > *S)
Recursively visit a statement or expression, by dispatching to Traverse*() based on the argument's dy...
This represents one expression.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
Stmt * getBody(const FunctionDecl *&Definition) const
Retrieve the body (definition) of the function.
Describes an C or C++ initializer list.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
A (possibly-)qualified type.
Represents a struct/union/class.
field_range fields() const
Stmt - This represents one statement.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types,...
bool isRecordType() const
RecordDecl * getAsRecordDecl() const
Retrieves the RecordDecl this type refers to.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Specialization of RecursiveASTVisitor that visits those nodes that are relevant to the dataflow analy...
Helper class for initialization of a record with an InitListExpr.
RecordInitListHelper(const InitListExpr *InitList)
llvm::DenseMap< const ValueDecl *, StorageLocation * > FieldToLoc
bool VisitCXXParenListInitExpr(CXXParenListInitExpr *ParenInitList) override
bool VisitInitListExpr(InitListExpr *InitList) override
bool VisitMemberExpr(MemberExpr *E) override
bool VisitDeclRefExpr(DeclRefExpr *E) override
void traverseConstructorInits(const CXXConstructorDecl *Ctor)
bool VisitCXXMemberCallExpr(CXXMemberCallExpr *C) override
ReferencedDeclsVisitor(ReferencedDecls &Referenced)
bool VisitDecl(Decl *D) override
Dataflow Directional Tag Classes.
static void getFieldsFromClassHierarchy(QualType Type, FieldSet &Fields)
static void insertIfFunction(const Decl &D, llvm::DenseSet< const FunctionDecl * > &Funcs)
static MemberExpr * getMemberForAccessor(const CXXMemberCallExpr &C)
ReferencedDecls getReferencedDecls(const FunctionDecl &FD)
Returns declarations that are declared in or referenced from FD.
static std::vector< const FieldDecl * > getFieldsForInitListExpr(const InitListT *InitList)
Returns the fields of a RecordDecl that are initialized by an InitListExpr or CXXParenListInitExpr,...
const Expr & ignoreCFGOmittedNodes(const Expr &E)
Skip past nodes that the CFG does not emit.
FieldSet getObjectFields(QualType Type)
Returns the set of all fields in the type.
static void insertIfGlobal(const Decl &D, llvm::DenseSet< const VarDecl * > &Globals)
static void insertIfLocal(const Decl &D, llvm::DenseSet< const VarDecl * > &Locals)
bool containsSameFields(const FieldSet &Fields, const RecordStorageLocation::FieldToLoc &FieldLocs)
Returns whether Fields and FieldLocs contain the same fields.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
@ Result
The result type of a method or function.
A collection of several types of declarations, all referenced from the same function.
llvm::DenseSet< const VarDecl * > Globals
All variables with static storage duration, notably including static member variables and static vari...
llvm::DenseSet< const VarDecl * > Locals
Local variables, not including parameters or static variables declared within a function.
llvm::DenseSet< const FunctionDecl * > Functions
Free functions and member functions which are referenced (but not necessarily called).
FieldSet Fields
Non-static member variables.
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