Go to the documentation of this file.
20 #include "llvm/ADT/ArrayRef.h"
22 using namespace clang;
31 D |= S->getDependence();
32 assert(!(D & ExprDependence::UnexpandedPack));
64 Result.Val.isLValue()) {
65 auto *VD = Result.Val.getLValueBase().dyn_cast<
const ValueDecl *>();
66 if (VD && VD->isTemplated()) {
67 auto *VarD = dyn_cast<VarDecl>(VD);
68 if (!VarD || !VarD->hasLocalStorage())
92 if (ExprKind != UETT_AlignOf && ExprKind != UETT_PreferredAlignOf)
99 if (
const auto *DRE = dyn_cast<DeclRefExpr>(NoParens))
101 else if (
const auto *ME = dyn_cast<MemberExpr>(NoParens))
102 D = ME->getMemberDecl();
106 if (I->isAlignmentErrorDependent())
108 if (I->isAlignmentDependent())
109 Deps |= ExprDependence::ValueInstantiation;
153 cast<ExplicitCastExpr>(E)->getTypeAsWritten()->getDependence()) |
180 if (
const auto *CompoundExprResult =
183 D |= ResultExpr->getDependence();
188 D |= ExprDependence::ValueInstantiation;
204 return ExprDependence::TypeValueInstantiation |
212 std::swap(Active, Inactive);
215 return (Active & ExprDependence::TypeValue) |
216 ((Cond | Active | Inactive) & ~ExprDependence::TypeValue);
221 for (
auto *E :
P->exprs())
222 D |= E->getDependence();
248 ExprDependence::Instantiation;
258 D |= ExprDependence::Instantiation;
313 assert(!(D & ExprDependence::UnexpandedPack));
342 D |= Dim->getDependence();
358 D |= ExprDependence::ValueInstantiation;
364 ExprDependence::TypeValueInstantiation;
373 return (Resume->getDependence() &
377 ExprDependence::TypeValueInstantiation;
382 ExprDependence::TypeValueInstantiation;
424 D |= LB->getDependence();
426 D |= Len->getDependence();
443 if (
auto *TSI = DD->getTypeSourceInfo()) {
449 D |= BE->getDependence();
451 D |= EE->getDependence();
453 D |= SE->getDependence();
466 ~NestedNameSpecifierDependence::Dependent);
470 for (
auto *Arg = FirstArg, *
End = FirstArg + NumArgs; Arg <
End; ++Arg)
478 Deps |= ExprDependence::UnexpandedPack;
492 return Deps | ExprDependence::TypeValueInstantiation;
494 Deps |= ExprDependence::Instantiation;
497 if (
Decl->getDeclName().getNameKind() ==
501 return Deps | ExprDependence::TypeValueInstantiation;
504 Deps |= ExprDependence::Instantiation;
522 if (isa<NonTypeTemplateParmDecl>(
Decl))
523 return Deps | ExprDependence::ValueInstantiation;
527 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
528 if (Var->mightBeUsableInConstantExpressions(Ctx)) {
529 if (
const Expr *Init = Var->getAnyInitializer()) {
530 if (Init->isValueDependent())
531 Deps |= ExprDependence::ValueInstantiation;
532 if (Init->containsErrors())
539 if (Var->isStaticDataMember() &&
540 Var->getDeclContext()->isDependentContext() &&
541 !Var->getFirstDecl()->hasInit()) {
545 Deps |= ExprDependence::TypeValueInstantiation;
546 }
else if (!
First->hasInit()) {
547 Deps |= ExprDependence::ValueInstantiation;
561 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Decl)) {
563 Deps |= ExprDependence::ValueInstantiation;
577 ExprDependence::ErrorDependent;
581 D |= S->getDependence();
599 D |= A->getDependence();
601 for (
auto *A : PreArgs)
602 D |= A->getDependence();
617 if (
FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
628 if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) {
638 for (
auto *A : E->
inits())
639 D |= A->getDependence();
646 D |= C->getDependence();
651 bool ContainsUnexpandedPack) {
652 auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack
659 return D | ExprDependence::TypeValueInstantiation;
668 if (D.isArrayDesignator())
670 else if (D.isArrayRangeDesignator())
673 Deps |= DesignatorDeps;
674 if (DesignatorDeps & ExprDependence::TypeValue)
675 Deps |= ExprDependence::TypeValueInstantiation;
683 D |= E->getDependence();
690 D |= E->getDependence();
717 ~NestedNameSpecifierDependence::Dependent);
723 if (Name.isInstantiationDependent())
724 D |= ExprDependence::Instantiation;
725 if (Name.containsUnexpandedParameterPack())
726 D |= ExprDependence::UnexpandedPack;
732 bool KnownInstantiationDependent,
733 bool KnownContainsUnexpandedParameterPack) {
736 Deps |= ExprDependence::TypeValue;
737 if (KnownInstantiationDependent)
738 Deps |= ExprDependence::Instantiation;
739 if (KnownContainsUnexpandedParameterPack)
740 Deps |= ExprDependence::UnexpandedPack;
744 ~NestedNameSpecifierDependence::Dependent);
745 for (
auto *D : E->
decls()) {
746 if (D->getDeclContext()->isDependentContext() ||
747 isa<UnresolvedUsingValueDecl>(D))
748 Deps |= ExprDependence::TypeValueInstantiation;
759 auto D = ExprDependence::TypeValue;
792 bool ContainsUnexpandedParameterPack) {
794 if (ContainsUnexpandedParameterPack)
795 D |= ExprDependence::UnexpandedPack;
800 auto D = ExprDependence::ValueInstantiation;
804 D |= A->getDependence() &
810 auto D = ExprDependence::TypeValueInstantiation;
826 auto D = ExprDependence::TypeValueInstantiation;
837 D |= A->getDependence();
843 for (
const auto *A : E->
getArgs())
850 bool ValueDependent) {
852 const auto InterestingDeps = TemplateArgumentDependence::Instantiation |
853 TemplateArgumentDependence::UnexpandedPack;
856 TA |= ArgLoc.getArgument().getDependence() & InterestingDeps;
857 if (TA == InterestingDeps)
882 KV.Value->getDependence());
883 if (KV.EllipsisLoc.isValid())
893 D |= R->getDependence();
897 D |= A->getDependence();
unsigned numOfIterators() const
Returns number of iterator definitions.
const Expr * getBase() const
Expr * getPattern()
Retrieve the pattern of the pack expansion.
An expression trait intrinsic.
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
Represents a reference to a non-type template parameter that has been substituted with a template arg...
ExprDependence getDependence() const
TypeSourceInfo * getWrittenTypeInfo() const
Stmt * getStmtExprResult()
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
bool isObjectReceiver() const
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
ObjCBoxedExpr - used for generalized expression boxing.
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
QualType getType() const
Return the type wrapped by this type source info.
const Expr * getSubExpr() const
TypeSourceInfo * getTypeSourceInfo() const
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
Expr * getCommon() const
getCommon - Return the common expression, written to the left of the condition.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Expr * getIndexExpr(unsigned Idx)
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
Represents a C99 designated initializer expression.
Expr * getBaseExpr() const
IteratorRange getIteratorRange(unsigned I)
Gets the iterator range for the given iterator.
A member reference to an MSPropertyDecl.
Expr * getSubExpr() const
Retrieve the temporary-generating subexpression whose value will be materialized into a glvalue.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
Expr * getExpr()
Get the initialization expression that will be used.
Represents a place-holder for an object not to be initialized by anything.
Expr * getSemanticForm()
Get an equivalent semantic form for this expression.
const Expr * getSubExpr() const
A (possibly-)qualified type.
TypeSourceInfo * getTypeSourceInfo() const
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Represents a member of a struct/union/class.
llvm::iterator_range< arg_iterator > arguments()
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
CompoundStmt * getSubStmt()
Describes an C or C++ initializer list.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
Expr * getCommonExpr() const
ExprDependence toExprDependence(TemplateArgumentDependence TA)
Computes dependencies of a reference with the name having template arguments with TA dependencies.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
unsigned getNumExpressions() const
bool isSuperReceiver() const
Represents a loop initializing the elements of an array.
Expr * getControllingExpr()
Return the controlling expression of this generic selection expression.
QualType getAllocatedType() const
Expr ** getSubExprs()
Retrieve the array of expressions.
Expr * getArrayRangeEnd(const Designator &D) const
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
Expr * getExprOperand() const
llvm::ArrayRef< TemplateArgumentLoc > arguments() const
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
TypeSourceInfo * getScopeTypeInfo() const
Retrieve the scope type in a qualified pseudo-destructor expression.
The base class of the type hierarchy.
Represents a folding of a pack over an operator.
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
ConditionalOperator - The ?: ternary operator.
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
A C++ throw-expression (C++ [except.throw]).
FullExpr - Represents a "full-expression" node.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
Represents a C++ functional cast expression that builds a temporary object.
ArrayRef< TemplateArgumentLoc > template_arguments() const
Expr * getOperand() const
const ASTTemplateArgumentListInfo * getTemplateArgsAsWritten() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
const DeclarationNameInfo & getNameInfo() const
Gets the full name info.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
MS property subscript expression.
bool isConditionDependent() const
A rewritten comparison expression that was originally written using operator syntax.
Represents a 'co_await' expression while the type of the promise is dependent.
Represents binding an expression to a temporary.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
llvm::iterator_range< decls_iterator > decls() const
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
const Expr * getSubExpr() const
A builtin binary operation expression such as "x + y" or "x <= y".
Expr * getInitializer()
The initializer of this new-expression.
TypeSourceInfo * getTypeSourceInfo() const
getTypeSourceInfo - Return the destination type.
constexpr XRayInstrMask None
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
CanThrowResult
Possible results from evaluation of a noexcept expression.
Expr ** getArgs()
Retrieve the call arguments.
Expr * getReplacement() const
Expr * getKeyExpr() const
ArrayRef< TemplateArgumentLoc > template_arguments() const
Expr * getBaseExpr() const
const BlockDecl * getBlockDecl() const
Represents the specialization of a concept - evaluates to a prvalue of type bool.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
TypeSourceInfo * getTypeSourceInfo() const
Expr * getExprOperand() const
ExprDependence turnTypeToValueDependence(ExprDependence D)
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
Decl * getIteratorDecl(unsigned I)
Gets the iterator declaration for the given iterator.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
unsigned getNumTemplateArgs() const
Retrieve the number of template arguments provided as part of this template-id.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
NestedNameSpecifier * getQualifier() const
If the member name was qualified, retrieves the nested-name-specifier that precedes the member name.
QualType getQueriedType() const
const Expr * getExprStmt() const
Location wrapper for a TemplateArgument.
EvalResult is a struct with detailed info about an evaluated expression.
Represents an implicitly-generated value initialization of an object of a given type.
Expr * getSourceExpr() const
The source expression of an opaque value expression is the expression which originally generated the ...
Represents a variable declaration or definition.
Expr * getLowerBound()
Get lower bound of array section.
unsigned getNumSubExprs() const
getNumSubExprs - Return the size of the SubExprs array.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
ObjCEncodeExpr, used for @encode in Objective-C.
ArrayRef< TemplateArgumentLoc > template_arguments() const
A default argument (C++ [dcl.fct.default]).
ArrayRef< Expr * > inits()
Represents a C++11 pack expansion that produces a sequence of expressions.
Expr * getLHS()
An array access can be written A[4] or 4[A] (both are equivalent).
ExprDependence computeDependence(FullExpr *E)
TypeSourceInfo * getAllocatedTypeSourceInfo() const
ArrayRef< Expr * > getInitExprs()
An expression that sends a message to the given Objective-C object or class.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
Expr * getQueriedExpression() const
Expr * getLength()
Get length of array section.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
bool isResultDependent() const
Whether this generic selection is result-dependent.
const Expr * getSubExpr() const
@ CXXConversionFunctionName
CompoundLiteralExpr - [C99 6.5.2.5].
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
llvm::MutableArrayRef< Designator > designators()
bool isArgumentType() const
Expr * getBase() const
Retrieve the base object of this member expressions, e.g., the x in x.m.
Represents a C++ struct/union/class.
bool isClassReceiver() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
const Expr * getBase() const
QualType getArgumentType() const
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
QualType getEncodedType() const
Iterator range representation begin:end[:step].
const DeclarationNameInfo & getMemberNameInfo() const
Retrieve the name of the member that this expression refers to.
llvm::iterator_range< semantics_iterator > semantics()
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Expr * getBase()
An array section can be written only as Base[LowerBound:Length].
ParenExpr - This represents a parethesized expression, e.g.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isIncompleteArrayType() const
Expr * getBase()
Fetches base expression of array shaping expression.
Represents a delete expression for memory deallocation and destructor calls, e.g.
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Decl - This represents one declaration (or definition), e.g.
bool isTypeOperand() const
Expr * getResumeExpr() const
ExprDependence toExprDependenceForImpliedType(TypeDependence D)
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
A qualified reference to a name whose declaration cannot yet be resolved.
Expr * getSrcExpr() const
getSrcExpr - Return the Expr to be converted.
const Expr * getSubExpr() const
Expr * getSubExpr() const
Get the initializer to use for each array element.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
ArrayRef< Expr * > getAssocExprs() const
Represents a C++ member access expression where the actual member referenced could not be resolved be...
bool isImplicitAccess() const
True if this is an implicit access, i.e.
TypeSourceInfo * getTypeOperandSourceInfo() const
Retrieve source information for the type operand.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
TypeSourceInfo * getDestroyedTypeInfo() const
Retrieve the source location information for the type being destroyed.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Represents the this expression in C++.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
[C99 6.4.2.2] - A predefined identifier such as func.
NestedNameSpecifier * getQualifier() const
Retrieve the nested-name-specifier that qualifies the member name.
ExprDependence turnValueToTypeDependence(ExprDependence D)
ArrayRef< Expr * > getDimensions() const
Fetches the dimensions for array shaping expression.
UnaryExprOrTypeTrait getKind() const
static ExprDependence getDependenceInExpr(DeclarationNameInfo Name)
const Expr * getInitializer() const
bool isParameterPack() const
Whether this declaration is a parameter pack.
bool isConditionTrue() const
isConditionTrue - Return whether the condition is true (i.e.
Expr * getSubExpr() const
OpenMP 5.0 [2.1.5, Array Sections].
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
std::optional< Expr * > getArraySize()
This might return std::nullopt even if isArray() returns true, since there might not be an array size...
const ASTConstraintSatisfaction & getSatisfaction() const
Get elaborated satisfaction info about the template arguments' satisfaction of the named concept.
TypeSourceInfo * getTypeSourceInfo() const
Expr * getResultExpr()
Return the result expression of this controlling expression.
llvm::iterator_range< arg_iterator > placement_arguments()
Represents a C11 generic selection.
An expression "T()" which creates a value-initialized rvalue of type T, which is a non-class type.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
A container of type source information.
bool isTypeOperand() const
NestedNameSpecifier * getQualifier() const
Fetches the nested-name qualifier, if one was given.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
ArrayRef< Expr * > subExpressions()
const DeclarationNameInfo & getNameInfo() const
Retrieve the name that this expression refers to.
TypeSourceInfo * getTypeSourceInfo()
Expr ** getElements()
Retrieve elements of array of literals.
Expr * getInit() const
Retrieve the initializer value.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Represents a call to the builtin function __builtin_va_arg.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
const TemplateArgumentLoc * getTemplateArgs() const
Retrieve the template arguments provided as part of this template-id.
Represents a list-initialization with parenthesis.
TypeDependence getDependence() const
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
const Expr * getBase() const
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
ExprDependence toExprDependenceAsWritten(TypeDependence D)
This represents one expression.
A use of a default initializer in a constructor or in aggregate initialization.
QualType getSuperReceiverType() const
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
Expr * getDimensionExpression() const
A reference to a declared variable, function, enum, etc.
Expr * getOperand() const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
Expr * getArrayRangeStart(const Designator &D) const
Represents a call to a C++ constructor.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
const LangOptions & getLangOpts() const
OpaqueValueExpr * getCommonExpr() const
Get the common subexpression shared by all initializations (the source array).
ExplicitCastExpr - An explicit cast written in the source code.
QualType getTypeAsWritten() const
Retrieve the type that is being constructed, as specified in the source code.
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
Expr * getArrayIndex(const Designator &D) const
DeclContext * getDeclContext()