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;
256 bool ContainsUnexpandedParameterPack) {
258 if (
E->getBlockDecl()->isDependentContext())
259 D |= ExprDependence::Instantiation;
260 if (ContainsUnexpandedParameterPack)
261 D |= ExprDependence::UnexpandedPack;
286 auto D = ExprDependence::None;
287 if (
E->isTypeOperand())
305 if (
E->isTypeOperand())
323 if (
E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
324 D |= ExprDependence::Type;
326 assert(!(
D & ExprDependence::UnexpandedPack));
331 auto *Op =
E->getSubExpr();
333 return ExprDependence::None;
343 if (
auto *TSI =
E->getTypeSourceInfo())
354 if (
auto *
Dim =
E->getDimensionExpression())
355 D |=
Dim->getDependence();
364 D |= ExprDependence::Value;
371 D |= ExprDependence::ValueInstantiation;
376 return (
E->getPattern()->
getDependence() & ~ExprDependence::UnexpandedPack) |
377 ExprDependence::TypeValueInstantiation;
386 if (
D & ExprDependence::TypeValueInstantiation)
388 ExprDependence::Instantiation;
391 if (Exprs.empty() || !
E->isFullySubstituted())
392 D |= PatternDep | ExprDependence::Instantiation;
394 std::optional<unsigned> Index =
E->getSelectedIndex();
395 assert(Index && *Index < Exprs.size() &&
"pack index out of bound");
396 D |= Exprs[*Index]->getDependence();
406 if (
auto *Resume =
E->getResumeExpr())
407 return (Resume->getDependence() &
408 (ExprDependence::TypeValue | ExprDependence::Error)) |
411 ExprDependence::TypeValueInstantiation;
416 ExprDependence::TypeValueInstantiation;
432 if (
E->isObjectReceiver())
434 if (
E->isSuperReceiver())
438 assert(
E->isClassReceiver());
439 return ExprDependence::None;
457 if (
auto *LB =
E->getLowerBound())
458 D |= LB->getDependence();
459 if (
auto *Len =
E->getLength())
460 D |= Len->getDependence();
462 if (
E->isOMPArraySection()) {
463 if (
auto *Stride =
E->getStride())
464 D |= Stride->getDependence();
479 for (
unsigned I = 0, End =
E->numOfIterators(); I < End; ++I) {
480 if (
auto *DD = cast_or_null<DeclaratorDecl>(
E->getIteratorDecl(I))) {
482 if (
auto *TSI = DD->getTypeSourceInfo()) {
488 D |= BE->getDependence();
490 D |= EE->getDependence();
492 D |= SE->getDependence();
501 auto Deps = ExprDependence::None;
503 if (
auto *NNS =
E->getQualifier())
505 ~NestedNameSpecifierDependence::Dependent);
507 if (
auto *FirstArg =
E->getTemplateArgs()) {
508 unsigned NumArgs =
E->getNumTemplateArgs();
509 for (
auto *Arg = FirstArg, *End = FirstArg + NumArgs; Arg < End; ++Arg)
513 auto *
Decl =
E->getDecl();
517 Deps |= ExprDependence::UnexpandedPack;
519 ExprDependence::Error;
535 Deps |= ExprDependence::TypeValueInstantiation;
537 Deps |= ExprDependence::Instantiation;
541 if (
E->isCapturedByCopyInLambdaWithExplicitObjectParameter())
542 Deps |= ExprDependence::Type;
545 if (
Decl->getDeclName().getNameKind() ==
549 return Deps | ExprDependence::TypeValueInstantiation;
552 Deps |= ExprDependence::Instantiation;
570 if (isa<NonTypeTemplateParmDecl>(
Decl))
571 return Deps | ExprDependence::ValueInstantiation;
575 if (
const auto *Var = dyn_cast<VarDecl>(
Decl)) {
576 if (
const Expr *
Init = Var->getAnyInitializer()) {
577 if (
Init->containsErrors())
578 Deps |= ExprDependence::Error;
580 if (Var->mightBeUsableInConstantExpressions(Ctx) &&
581 Init->isValueDependent())
582 Deps |= ExprDependence::ValueInstantiation;
587 if (Var->isStaticDataMember() &&
588 Var->getDeclContext()->isDependentContext() &&
589 !Var->getFirstDecl()->hasInit()) {
593 Deps |= ExprDependence::TypeValueInstantiation;
594 }
else if (!
First->hasInit()) {
595 Deps |= ExprDependence::ValueInstantiation;
609 if (
auto *MD = dyn_cast<CXXMethodDecl>(
Decl)) {
611 Deps |= ExprDependence::ValueInstantiation;
625 ExprDependence::ErrorDependent;
628 for (
auto *S :
E->subExpressions())
629 D |= S->getDependence();
646 D |= ExprDependence::Type;
649 D |= A->getDependence();
651 for (
auto *A : PreArgs)
652 D |= A->getDependence();
659 for (
unsigned I = 0, N =
E->getNumExpressions(); I < N; ++I)
665 auto D = ExprDependence::None;
666 if (Name.isInstantiationDependent())
667 D |= ExprDependence::Instantiation;
668 if (Name.containsUnexpandedParameterPack())
669 D |= ExprDependence::UnexpandedPack;
677 if (
auto *NNS =
E->getQualifier())
679 ~NestedNameSpecifierDependence::Dependent);
681 for (
const auto &A :
E->template_arguments())
684 auto *MemberDecl =
E->getMemberDecl();
685 if (
FieldDecl *FD = dyn_cast<FieldDecl>(MemberDecl)) {
696 if (FD && FD->isBitField() && FD->getBitWidth()->isValueDependent()) {
697 D |= ExprDependence::Type;
704 auto D = ExprDependence::None;
705 for (
auto *A :
E->inits())
706 D |= A->getDependence();
713 D |=
C->getDependence();
718 bool ContainsUnexpandedPack) {
719 auto D = ContainsUnexpandedPack ? ExprDependence::UnexpandedPack
720 : ExprDependence::None;
721 for (
auto *AE :
E->getAssocExprs())
722 D |= AE->getDependence() & ExprDependence::Error;
724 if (
E->isExprPredicate())
730 if (
E->isResultDependent())
731 return D | ExprDependence::TypeValueInstantiation;
738 for (
const auto &
D :
E->designators()) {
739 auto DesignatorDeps = ExprDependence::None;
740 if (
D.isArrayDesignator())
742 else if (
D.isArrayRangeDesignator())
745 Deps |= DesignatorDeps;
746 if (DesignatorDeps & ExprDependence::TypeValue)
747 Deps |= ExprDependence::TypeValueInstantiation;
760 auto D = ExprDependence::None;
770 auto Size =
E->getArraySize();
773 if (
auto *I =
E->getInitializer())
775 for (
auto *A :
E->placement_arguments())
782 if (
auto *TSI =
E->getDestroyedTypeInfo())
784 if (
auto *ST =
E->getScopeTypeInfo())
787 if (
auto *Q =
E->getQualifier())
789 ~NestedNameSpecifierDependence::Dependent);
795 bool KnownInstantiationDependent,
796 bool KnownContainsUnexpandedParameterPack) {
797 auto Deps = ExprDependence::None;
799 Deps |= ExprDependence::TypeValue;
800 if (KnownInstantiationDependent)
801 Deps |= ExprDependence::Instantiation;
802 if (KnownContainsUnexpandedParameterPack)
803 Deps |= ExprDependence::UnexpandedPack;
805 if (
auto *Q =
E->getQualifier())
807 ~NestedNameSpecifierDependence::Dependent);
808 for (
auto *
D :
E->decls()) {
810 isa<UnresolvedUsingValueDecl>(
D))
811 Deps |= ExprDependence::TypeValueInstantiation;
816 for (
const auto &A :
E->template_arguments())
822 auto D = ExprDependence::TypeValue;
824 if (
auto *Q =
E->getQualifier())
826 for (
const auto &A :
E->template_arguments())
834 for (
auto *A :
E->arguments())
855 bool ContainsUnexpandedParameterPack) {
857 if (ContainsUnexpandedParameterPack)
858 D |= ExprDependence::UnexpandedPack;
863 auto D = ExprDependence::ValueInstantiation;
866 for (
auto *A :
E->arguments())
867 D |= A->getDependence() &
868 (ExprDependence::UnexpandedPack | ExprDependence::Error);
873 auto D = ExprDependence::TypeValueInstantiation;
874 if (!
E->isImplicitAccess())
876 if (
auto *Q =
E->getQualifier())
879 for (
const auto &A :
E->template_arguments())
889 auto D = ExprDependence::TypeValueInstantiation;
890 for (
const auto *
C : {
E->getLHS(),
E->getRHS()}) {
898 auto D = ExprDependence::None;
899 for (
const auto *A :
E->getInitExprs())
900 D |= A->getDependence();
905 auto D = ExprDependence::None;
906 for (
const auto *A :
E->getArgs())
913 bool ValueDependent) {
914 auto TA = TemplateArgumentDependence::None;
915 const auto InterestingDeps = TemplateArgumentDependence::Instantiation |
916 TemplateArgumentDependence::UnexpandedPack;
918 E->getTemplateArgsAsWritten()->arguments()) {
919 TA |= ArgLoc.getArgument().getDependence() & InterestingDeps;
920 if (TA == InterestingDeps)
925 ValueDependent ? ExprDependence::Value : ExprDependence::None;
927 if(!ValueDependent &&
E->getSatisfaction().ContainsErrors)
928 Res |= ExprDependence::Error;
933 auto D = ExprDependence::None;
934 Expr **Elements =
E->getElements();
935 for (
unsigned I = 0, N =
E->getNumElements(); I != N; ++I)
941 auto Deps = ExprDependence::None;
942 for (
unsigned I = 0, N =
E->getNumElements(); I < N; ++I) {
943 auto KV =
E->getKeyValueElement(I);
945 KV.Value->getDependence());
946 if (KV.EllipsisLoc.isValid())
954 auto D = ExprDependence::None;
955 if (
auto *R =
E->getInstanceReceiver())
956 D |= R->getDependence();
959 for (
auto *A :
E->arguments())
960 D |= A->getDependence();
967 return ExprDependence::None;
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.
This expression type represents an asterisk in an OpenACC Size-Expr, used in the 'tile' and 'gang' cl...
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].