20#include "llvm/ADT/ArrayRef.h"
30 if (
auto *S =
E->getSourceExpr())
31 D |= S->getDependence();
32 assert(!(
D & ExprDependence::UnexpandedPack));
57 if (Ctx.
getLangOpts().CPlusPlus &&
E->getOpcode() == UO_AddrOf &&
58 !(Dep & ExprDependence::Value)) {
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())
69 Dep |= ExprDependence::Value;
80 if (
E->isArgumentType())
87 if (ArgDeps & ExprDependence::Type)
88 Deps |= ExprDependence::Value;
91 auto ExprKind =
E->getKind();
92 if (ExprKind != UETT_AlignOf && ExprKind != UETT_PreferredAlignOf)
94 if ((Deps & ExprDependence::Value) && (Deps & ExprDependence::Instantiation))
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())
107 Deps |= ExprDependence::Error;
108 if (I->isAlignmentDependent())
109 Deps |= ExprDependence::ValueInstantiation;
121 : ExprDependence::None);
137 if (
auto *S =
E->getSubExpr())
153 cast<ExplicitCastExpr>(
E)->getTypeAsWritten()->getDependence()) |
155 if (
auto *S =
E->getSubExpr())
180 if (
const auto *CompoundExprResult =
181 dyn_cast_or_null<ValueStmt>(
E->getSubStmt()->getStmtExprResult()))
183 D |= ResultExpr->getDependence();
188 D |= ExprDependence::ValueInstantiation;
203 if (
E->isConditionDependent())
204 return ExprDependence::TypeValueInstantiation |
211 if (!
E->isConditionTrue())
212 std::swap(Active, Inactive);
215 return (Active & ExprDependence::TypeValue) |
216 ((Cond | Active | Inactive) & ~ExprDependence::TypeValue);
220 auto D = ExprDependence::None;
221 for (
auto *
E :
P->exprs())
235 (ExprDependence::Instantiation | ExprDependence::Error);
248 ExprDependence::Instantiation;
257 if (
E->getBlockDecl()->isDependentContext())
258 D |= ExprDependence::Instantiation;
283 auto D = ExprDependence::None;
284 if (
E->isTypeOperand())
302 if (
E->isTypeOperand())
320 if (
E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
321 D |= ExprDependence::Type;
323 assert(!(
D & ExprDependence::UnexpandedPack));
328 auto *Op =
E->getSubExpr();
330 return ExprDependence::None;
340 if (
auto *TSI =
E->getTypeSourceInfo())
351 if (
auto *Dim =
E->getDimensionExpression())
352 D |= Dim->getDependence();
361 D |= ExprDependence::Value;
368 D |= ExprDependence::ValueInstantiation;
373 return (
E->getPattern()->
getDependence() & ~ExprDependence::UnexpandedPack) |
374 ExprDependence::TypeValueInstantiation;
383 if (
D & ExprDependence::TypeValueInstantiation)
385 ExprDependence::Instantiation;
389 D |= PatternDep | ExprDependence::Instantiation;
392 std::optional<unsigned> Index =
E->getSelectedIndex();
393 assert(Index && *Index < Exprs.size() &&
"pack index out of bound");
394 D |= Exprs[*Index]->getDependence();
404 if (
auto *Resume =
E->getResumeExpr())
405 return (Resume->getDependence() &
406 (ExprDependence::TypeValue | ExprDependence::Error)) |
409 ExprDependence::TypeValueInstantiation;
414 ExprDependence::TypeValueInstantiation;
430 if (
E->isObjectReceiver())
432 if (
E->isSuperReceiver())
436 assert(
E->isClassReceiver());
437 return ExprDependence::None;
455 if (
auto *LB =
E->getLowerBound())
456 D |= LB->getDependence();
457 if (
auto *Len =
E->getLength())
458 D |= Len->getDependence();
460 if (
E->isOMPArraySection()) {
461 if (
auto *Stride =
E->getStride())
462 D |= Stride->getDependence();
469 for (
Expr *Dim:
E->getDimensions())
477 for (
unsigned I = 0, End =
E->numOfIterators(); I < End; ++I) {
478 if (
auto *DD = cast_or_null<DeclaratorDecl>(
E->getIteratorDecl(I))) {
480 if (
auto *TSI = DD->getTypeSourceInfo()) {
486 D |= BE->getDependence();
488 D |= EE->getDependence();
490 D |= SE->getDependence();
499 auto Deps = ExprDependence::None;
501 if (
auto *NNS =
E->getQualifier())
503 ~NestedNameSpecifierDependence::Dependent);
505 if (
auto *FirstArg =
E->getTemplateArgs()) {
506 unsigned NumArgs =
E->getNumTemplateArgs();
507 for (
auto *Arg = FirstArg, *End = FirstArg + NumArgs; Arg < End; ++Arg)
511 auto *
Decl =
E->getDecl();
515 Deps |= ExprDependence::UnexpandedPack;
517 ExprDependence::Error;
533 Deps |= ExprDependence::TypeValueInstantiation;
535 Deps |= ExprDependence::Instantiation;
539 if (
E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
540 Deps |= ExprDependence::Type;
543 if (
Decl->getDeclName().getNameKind() ==
547 return Deps | ExprDependence::TypeValueInstantiation;
550 Deps |= ExprDependence::Instantiation;
568 if (isa<NonTypeTemplateParmDecl>(
Decl))
569 return Deps | ExprDependence::ValueInstantiation;
573 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
574 if (
const Expr *
Init = Var->getAnyInitializer()) {
575 if (
Init->containsErrors())
576 Deps |= ExprDependence::Error;
578 if (Var->mightBeUsableInConstantExpressions(Ctx) &&
579 Init->isValueDependent())
580 Deps |= ExprDependence::ValueInstantiation;
585 if (Var->isStaticDataMember() &&
586 Var->getDeclContext()->isDependentContext() &&
587 !Var->getFirstDecl()->hasInit()) {
591 Deps |= ExprDependence::TypeValueInstantiation;
592 }
else if (!
First->hasInit()) {
593 Deps |= ExprDependence::ValueInstantiation;
607 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Decl)) {
609 Deps |= ExprDependence::ValueInstantiation;
623 ExprDependence::ErrorDependent;
626 for (
auto *S :
E->subExpressions())
627 D |= S->getDependence();
644 D |= ExprDependence::Type;
647 D |= A->getDependence();
649 for (
auto *A : PreArgs)
650 D |= A->getDependence();
657 for (
unsigned I = 0, N =
E->getNumExpressions(); I < N; ++I)
663 auto D = ExprDependence::None;
664 if (Name.isInstantiationDependent())
665 D |= ExprDependence::Instantiation;
666 if (Name.containsUnexpandedParameterPack())
667 D |= ExprDependence::UnexpandedPack;
675 if (
auto *NNS =
E->getQualifier())
677 ~NestedNameSpecifierDependence::Dependent);
679 for (
const auto &A :
E->template_arguments())
682 auto *MemberDecl =
E->getMemberDecl();
683 if (
FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
694 if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) {
695 D |= ExprDependence::Type;
702 auto D = ExprDependence::None;
703 for (
auto *A :
E->inits())
704 D |= A->getDependence();
711 D |=
C->getDependence();
716 bool ContainsUnexpandedPack) {
717 auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack
718 : ExprDependence::None;
719 for (
auto *AE :
E->getAssocExprs())
720 D |= AE->getDependence() & ExprDependence::Error;
722 if (
E->isExprPredicate())
728 if (
E->isResultDependent())
729 return D | ExprDependence::TypeValueInstantiation;
736 for (
const auto &
D :
E->designators()) {
737 auto DesignatorDeps = ExprDependence::None;
738 if (
D.isArrayDesignator())
740 else if (
D.isArrayRangeDesignator())
743 Deps |= DesignatorDeps;
744 if (DesignatorDeps & ExprDependence::TypeValue)
745 Deps |= ExprDependence::TypeValueInstantiation;
758 auto D = ExprDependence::None;
768 auto Size =
E->getArraySize();
771 if (
auto *I =
E->getInitializer())
773 for (
auto *A :
E->placement_arguments())
780 if (
auto *TSI =
E->getDestroyedTypeInfo())
782 if (
auto *ST =
E->getScopeTypeInfo())
785 if (
auto *Q =
E->getQualifier())
787 ~NestedNameSpecifierDependence::Dependent);
793 bool KnownInstantiationDependent,
794 bool KnownContainsUnexpandedParameterPack) {
795 auto Deps = ExprDependence::None;
797 Deps |= ExprDependence::TypeValue;
798 if (KnownInstantiationDependent)
799 Deps |= ExprDependence::Instantiation;
800 if (KnownContainsUnexpandedParameterPack)
801 Deps |= ExprDependence::UnexpandedPack;
803 if (
auto *Q =
E->getQualifier())
805 ~NestedNameSpecifierDependence::Dependent);
806 for (
auto *
D :
E->decls()) {
808 isa<UnresolvedUsingValueDecl>(
D))
809 Deps |= ExprDependence::TypeValueInstantiation;
814 for (
const auto &A :
E->template_arguments())
820 auto D = ExprDependence::TypeValue;
822 if (
auto *Q =
E->getQualifier())
824 for (
const auto &A :
E->template_arguments())
832 for (
auto *A :
E->arguments())
853 bool ContainsUnexpandedParameterPack) {
855 if (ContainsUnexpandedParameterPack)
856 D |= ExprDependence::UnexpandedPack;
861 auto D = ExprDependence::ValueInstantiation;
864 for (
auto *A :
E->arguments())
865 D |= A->getDependence() &
866 (ExprDependence::UnexpandedPack | ExprDependence::Error);
871 auto D = ExprDependence::TypeValueInstantiation;
872 if (!
E->isImplicitAccess())
874 if (
auto *Q =
E->getQualifier())
877 for (
const auto &A :
E->template_arguments())
887 auto D = ExprDependence::TypeValueInstantiation;
888 for (
const auto *
C : {
E->getLHS(),
E->getRHS()}) {
896 auto D = ExprDependence::None;
897 for (
const auto *A :
E->getInitExprs())
898 D |= A->getDependence();
903 auto D = ExprDependence::None;
904 for (
const auto *A :
E->getArgs())
911 bool ValueDependent) {
912 auto TA = TemplateArgumentDependence::None;
913 const auto InterestingDeps = TemplateArgumentDependence::Instantiation |
914 TemplateArgumentDependence::UnexpandedPack;
916 E->getTemplateArgsAsWritten()->arguments()) {
917 TA |= ArgLoc.getArgument().getDependence() & InterestingDeps;
918 if (TA == InterestingDeps)
923 ValueDependent ? ExprDependence::Value : ExprDependence::None;
925 if(!ValueDependent &&
E->getSatisfaction().ContainsErrors)
926 Res |= ExprDependence::Error;
931 auto D = ExprDependence::None;
932 Expr **Elements =
E->getElements();
933 for (
unsigned I = 0, N =
E->getNumElements(); I != N; ++I)
939 auto Deps = ExprDependence::None;
940 for (
unsigned I = 0, N =
E->getNumElements(); I < N; ++I) {
941 auto KV =
E->getKeyValueElement(I);
943 KV.Value->getDependence());
944 if (KV.EllipsisLoc.isValid())
952 auto D = ExprDependence::None;
953 if (
auto *R =
E->getInstanceReceiver())
954 D |= R->getDependence();
957 for (
auto *A :
E->arguments())
958 D |= A->getDependence();
static ExprDependence getDependenceInExpr(DeclarationNameInfo Name)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const LangOptions & getLangOpts() const
Represents a loop initializing the elements of an array.
This class represents BOTH the OpenMP Array Section and OpenACC 'subarray', with a boolean differenti...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent.
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
AtomicExpr - Variadic atomic builtins: __atomic_exchange, __atomic_fetch_*, __atomic_load,...
static unsigned getNumSubExprs(AtomicOp Op)
Determine the number of arguments the specified atomic builtin should have.
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
A builtin binary operation expression such as "x + y" or "x <= y".
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents binding an expression to a temporary.
Represents a call to a C++ constructor.
A default argument (C++ [dcl.fct.default]).
A use of a default initializer in a constructor or in aggregate initialization.
Represents a delete expression for memory deallocation and destructor calls, e.g.
Represents a C++ member access expression where the actual member referenced could not be resolved be...
Represents a folding of a pack over an operator.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)".
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
Represents a list-initialization with parenthesis.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
Represents a C++ struct/union/class.
bool isCurrentInstantiation(const DeclContext *CurContext) const
Determine whether this dependent class is a current instantiation, when viewed from within the given ...
A rewritten comparison expression that was originally written using operator syntax.
An expression "T()" which creates an rvalue of a non-class type T.
Implicit construction of a std::initializer_list<T> object from an array temporary within list-initia...
Represents a C++ functional cast expression that builds a temporary object.
Represents the this expression in C++.
A C++ throw-expression (C++ [except.throw]).
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
Describes an explicit type conversion that uses functional notion but could not be resolved because o...
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
CompoundLiteralExpr - [C99 6.5.2.5].
Represents the specialization of a concept - evaluates to a prvalue of type bool.
ConditionalOperator - The ?: ternary operator.
ConvertVectorExpr - Clang builtin function __builtin_convertvector This AST node provides support for...
Represents an expression that might suspend coroutine execution; either a co_await or co_yield expres...
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
A reference to a declared variable, function, enum, etc.
Decl - This represents one declaration (or definition), e.g.
bool isParameterPack() const
Whether this declaration is a parameter pack.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
DeclContext * getDeclContext()
@ CXXConversionFunctionName
Represents a 'co_await' expression while the type of the promise is dependent.
A qualified reference to a name whose declaration cannot yet be resolved.
Represents a C99 designated initializer expression.
ExplicitCastExpr - An explicit cast written in the source code.
This represents one expression.
bool isTypeDependent() const
Determines whether the type of this expression depends on.
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point.
bool EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx, ConstantExprKind Kind=ConstantExprKind::Normal) const
Evaluate an expression that is required to be a constant expression.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on.
ExprDependence getDependence() const
An expression trait intrinsic.
ExtVectorElementExpr - This represents access to specific elements of a vector, and may occur on the ...
Represents a member of a struct/union/class.
FullExpr - Represents a "full-expression" node.
Represents a C11 generic selection.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
Represents an implicitly-generated value initialization of an object of a given type.
Describes an C or C++ initializer list.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
A member reference to an MSPropertyDecl.
MS property subscript expression.
Represents a prvalue temporary that is written into memory so that a reference can bind to it.
MatrixSubscriptExpr - Matrix subscript expression for the MatrixType extension.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Represents a place-holder for an object not to be initialized by anything.
An explicit cast in C or a C-style cast in C++, which uses the syntax ([s1][s2]......
OpenMP 5.0 [2.1.6 Iterators] Iterators are identifiers that expand to multiple values in the clause o...
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
ObjCBoxedExpr - used for generalized expression boxing.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
ObjCEncodeExpr, used for @encode in Objective-C.
ObjCIndirectCopyRestoreExpr - Represents the passing of a function argument by indirect copy-restore ...
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
An expression that sends a message to the given Objective-C object or class.
ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.
ObjCSubscriptRefExpr - used for array and dictionary subscripting.
OffsetOfExpr - [C99 7.17] - This represents an expression of the form offsetof(record-type,...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr.
Represents a C++11 pack expansion that produces a sequence of expressions.
ParenExpr - This represents a parenthesized expression, e.g.
[C99 6.4.2.2] - A predefined identifier such as func.
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ArrayRef< Expr * > semantics()
Expr * getSyntacticForm()
Return the syntactic form of this expression, i.e.
A (possibly-)qualified type.
Frontend produces RecoveryExprs on semantic errors that prevent creating other well-formed expression...
ShuffleVectorExpr - clang-specific builtin-in function __builtin_shufflevector.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
Represents a reference to a non-type template parameter that has been substituted with a template arg...
Location wrapper for a TemplateArgument.
A container of type source information.
QualType getType() const
Return the type wrapped by this type source info.
A type trait used in the implementation of various C++11 and Library TR1 trait templates.
The base class of the type hierarchy.
bool isIncompleteArrayType() const
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
TypeDependence getDependence() const
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Represents a call to the builtin function __builtin_va_arg.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
const Expr * getExprStmt() const
Represents a variable declaration or definition.
The JSON file list parser is used to communicate input to InstallAPI.
ExprDependence toExprDependence(TemplateArgumentDependence TA)
Computes dependencies of a reference with the name having template arguments with TA dependencies.
CanThrowResult
Possible results from evaluation of a noexcept expression.
ExprDependence turnTypeToValueDependence(ExprDependence D)
ExprDependence toExprDependenceAsWritten(TypeDependence D)
ExprDependence computeDependence(FullExpr *E)
ExprDependence turnValueToTypeDependence(ExprDependence D)
ExprDependence toExprDependenceForImpliedType(TypeDependence D)
const FunctionProtoType * T
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspon...
EvalResult is a struct with detailed info about an evaluated expression.
Iterator range representation begin:end[:step].