class Expr

Declaration

class Expr : public ValueStmt { /* full declaration omitted */ };

Description

This represents one expression. Note that Expr's are subclasses of Stmt. This allows an expression to be transparently used any place a Stmt is required.

Declared at: clang/include/clang/AST/Expr.h:109

Inherits from: ValueStmt

Member Variables

private clang::QualType TR

Inherited from Stmt:

protected

Method Overview

Inherited from ValueStmt:

Inherited from Stmt:

Methods

clang::Expr::Classification Classify(
    clang::ASTContext& Ctx) const

Description

Classify - Classify this expression according to the C++11 expression taxonomy. C++11 defines ([basic.lval]) a new taxonomy of expressions to replace the old lvalue vs rvalue. This function determines the type of expression this is. There are three expression types: - lvalues are classical lvalues as in C++03. - prvalues are equivalent to rvalues in C++03. - xvalues are expressions yielding unnamed rvalue references, e.g. a function returning an rvalue reference. lvalues and xvalues are collectively referred to as glvalues, while prvalues and xvalues together form rvalues.

Declared at: clang/include/clang/AST/Expr.h:398

Parameters

clang::ASTContext& Ctx

clang::Expr::Classification ClassifyImpl(
    clang::ASTContext& Ctx,
    clang::SourceLocation* Loc) const

Declared at: clang/include/clang/AST/Expr.h:453

Parameters

clang::ASTContext& Ctx
clang::SourceLocation* Loc

clang::Expr::LValueClassification ClassifyLValue(
    clang::ASTContext& Ctx) const

Description

Reasons why an expression might not be an l-value.

Declared at: clang/include/clang/AST/Expr.h:288

Parameters

clang::ASTContext& Ctx

clang::Expr::Classification ClassifyModifiable(
    clang::ASTContext& Ctx,
    clang::SourceLocation& Loc) const

Description

ClassifyModifiable - Classify this expression according to the C++11 expression taxonomy, and see if it is valid on the left side of an assignment. This function extends classify in that it also tests whether the expression is modifiable (C99 6.3.2.1p1).

Declared at: clang/include/clang/AST/Expr.h:410

Parameters

clang::ASTContext& Ctx
clang::SourceLocation& Loc
A source location that might be filled with a relevant location if the expression is not modifiable.

bool EvaluateAsBooleanCondition(
    bool& Result,
    const clang::ASTContext& Ctx,
    bool InConstantContext = false) const

Description

EvaluateAsBooleanCondition - Return true if this is a constant which we can fold and convert to a boolean condition using any crazy technique that we want to, even if the expression has side-effects.

Declared at: clang/include/clang/AST/Expr.h:634

Parameters

bool& Result
const clang::ASTContext& Ctx
bool InConstantContext = false

bool EvaluateAsConstantExpr(
    clang::Expr::EvalResult& Result,
    const clang::ASTContext& Ctx,
    clang::Expr::ConstantExprKind Kind =
        ConstantExprKind::Normal) const

Description

Evaluate an expression that is required to be a constant expression. Does not check the syntactic constraints for C and C++98 constant expressions.

Declared at: clang/include/clang/AST/Expr.h:735

Parameters

clang::Expr::EvalResult& Result
const clang::ASTContext& Ctx
clang::Expr::ConstantExprKind Kind = ConstantExprKind::Normal

bool EvaluateAsFixedPoint(
    clang::Expr::EvalResult& Result,
    const clang::ASTContext& Ctx,
    clang::Expr::SideEffectsKind
        AllowSideEffects = SE_NoSideEffects,
    bool InConstantContext = false) const

Description

EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a fixed point value.

Declared at: clang/include/clang/AST/Expr.h:659

Parameters

clang::Expr::EvalResult& Result
const clang::ASTContext& Ctx
clang::Expr::SideEffectsKind AllowSideEffects = SE_NoSideEffects
bool InConstantContext = false

bool EvaluateAsFloat(
    llvm::APFloat& Result,
    const clang::ASTContext& Ctx,
    clang::Expr::SideEffectsKind
        AllowSideEffects = SE_NoSideEffects,
    bool InConstantContext = false) const

Description

EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point value, using any crazy technique that we want to.

Declared at: clang/include/clang/AST/Expr.h:653

Parameters

llvm::APFloat& Result
const clang::ASTContext& Ctx
clang::Expr::SideEffectsKind AllowSideEffects = SE_NoSideEffects
bool InConstantContext = false

bool EvaluateAsInitializer(
    clang::APValue& Result,
    const clang::ASTContext& Ctx,
    const clang::VarDecl* VD,
    SmallVectorImpl<clang::PartialDiagnosticAt>&
        Notes,
    bool IsConstantInitializer) const

Description

EvaluateAsInitializer - Evaluate an expression as if it were the initializer of the given declaration. Returns true if the initializer can be folded to a constant, and produces any relevant notes. In C++11, notes will be produced if the expression is not a constant expression.

Declared at: clang/include/clang/AST/Expr.h:704

Parameters

clang::APValue& Result
const clang::ASTContext& Ctx
const clang::VarDecl* VD
SmallVectorImpl<clang::PartialDiagnosticAt>& Notes
bool IsConstantInitializer

bool EvaluateAsInt(
    clang::Expr::EvalResult& Result,
    const clang::ASTContext& Ctx,
    clang::Expr::SideEffectsKind
        AllowSideEffects = SE_NoSideEffects,
    bool InConstantContext = false) const

Description

EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer, using any crazy technique that we want to.

Declared at: clang/include/clang/AST/Expr.h:646

Parameters

clang::Expr::EvalResult& Result
const clang::ASTContext& Ctx
clang::Expr::SideEffectsKind AllowSideEffects = SE_NoSideEffects
bool InConstantContext = false

bool EvaluateAsLValue(
    clang::Expr::EvalResult& Result,
    const clang::ASTContext& Ctx,
    bool InConstantContext = false) const

Description

EvaluateAsLValue - Evaluate an expression to see if we can fold it to an lvalue with link time known address, with no side-effects.

Declared at: clang/include/clang/AST/Expr.h:697

Parameters

clang::Expr::EvalResult& Result
const clang::ASTContext& Ctx
bool InConstantContext = false

bool EvaluateAsRValue(
    clang::Expr::EvalResult& Result,
    const clang::ASTContext& Ctx,
    bool InConstantContext = false) const

Description

EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy technique (that has nothing to do with language standards) that we want to, even if the expression has side-effects. If this function returns true, it returns the folded constant in Result. If the expression is a glvalue, an lvalue-to-rvalue conversion will be applied.

Declared at: clang/include/clang/AST/Expr.h:627

Parameters

clang::Expr::EvalResult& Result
const clang::ASTContext& Ctx
bool InConstantContext = false

void EvaluateForOverflow(
    const clang::ASTContext& Ctx) const

Declared at: clang/include/clang/AST/Expr.h:693

Parameters

const clang::ASTContext& Ctx

llvm::APSInt EvaluateKnownConstInt(
    const clang::ASTContext& Ctx,
    SmallVectorImpl<clang::PartialDiagnosticAt>*
        Diag = nullptr) const

Description

EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer. This must be called on an expression that constant folds to an integer.

Declared at: clang/include/clang/AST/Expr.h:685

Parameters

const clang::ASTContext& Ctx
SmallVectorImpl<clang::PartialDiagnosticAt>* Diag = nullptr

llvm::APSInt EvaluateKnownConstIntCheckOverflow(
    const clang::ASTContext& Ctx,
    SmallVectorImpl<clang::PartialDiagnosticAt>*
        Diag = nullptr) const

Declared at: clang/include/clang/AST/Expr.h:689

Parameters

const clang::ASTContext& Ctx
SmallVectorImpl<clang::PartialDiagnosticAt>* Diag = nullptr

bool EvaluateWithSubstitution(
    clang::APValue& Value,
    clang::ASTContext& Ctx,
    const clang::FunctionDecl* Callee,
    ArrayRef<const clang::Expr*> Args,
    const clang::Expr* This = nullptr) const

Description

EvaluateWithSubstitution - Evaluate an expression as if from the context of a call to the given function with the given arguments, inside an unevaluated context. Returns true if the expression could be folded to a constant.

Declared at: clang/include/clang/AST/Expr.h:713

Parameters

clang::APValue& Value
clang::ASTContext& Ctx
const clang::FunctionDecl* Callee
ArrayRef<const clang::Expr*> Args
const clang::Expr* This = nullptr

Expr(const clang::Expr&)

Declared at: clang/include/clang/AST/Expr.h:114

Parameters

const clang::Expr&

Expr(clang::Stmt::StmtClass SC,
     clang::Stmt::EmptyShell)

Description

Construct an empty expression.

Declared at: clang/include/clang/AST/Expr.h:130

Parameters

clang::Stmt::StmtClass SC
clang::Stmt::EmptyShell

Expr(clang::Stmt::StmtClass SC,
     clang::QualType T,
     clang::ExprValueKind VK,
     clang::ExprObjectKind OK)

Declared at: clang/include/clang/AST/Expr.h:120

Parameters

clang::Stmt::StmtClass SC
clang::QualType T
clang::ExprValueKind VK
clang::ExprObjectKind OK

Expr(clang::Expr&&)

Declared at: clang/include/clang/AST/Expr.h:115

Parameters

clang::Expr&&

Expr()

Declared at: clang/include/clang/AST/Expr.h:113

bool HasSideEffects(
    const clang::ASTContext& Ctx,
    bool IncludePossibleEffects = true) const

Description

HasSideEffects - This routine returns true for all those expressions which have any effect other than producing a value. Example is a function call, volatile variable read, or throwing an exception. If IncludePossibleEffects is false, this call treats certain expressions with potential side effects (such as function call-like expressions, instantiation-dependent expressions, or invocations from a macro) as not having side effects.

Declared at: clang/include/clang/AST/Expr.h:675

Parameters

const clang::ASTContext& Ctx
bool IncludePossibleEffects = true

clang::Expr* IgnoreCasts()

Description

Skip past any casts which might surround this expression until reaching a fixed point. Skips: * CastExpr * FullExpr * MaterializeTemporaryExpr * SubstNonTypeTemplateParmExpr

Declared at: clang/include/clang/AST/Expr.h:836

const clang::Expr* IgnoreCasts() const

Declared at: clang/include/clang/AST/Expr.h:837

const clang::Expr*
IgnoreConversionOperatorSingleStep() const

Declared at: clang/include/clang/AST/Expr.h:899

clang::Expr* IgnoreConversionOperatorSingleStep()

Description

Skip conversion operators. If this Expr is a call to a conversion operator, return the argument.

Declared at: clang/include/clang/AST/Expr.h:898

clang::Expr* IgnoreImpCasts()

Description

Skip past any implicit casts which might surround this expression until reaching a fixed point. Skips: * ImplicitCastExpr * FullExpr

Declared at: clang/include/clang/AST/Expr.h:825

const clang::Expr* IgnoreImpCasts() const

Declared at: clang/include/clang/AST/Expr.h:826

clang::Expr* IgnoreImplicit()

Description

Skip past any implicit AST nodes which might surround this expression until reaching a fixed point. Skips: * What IgnoreImpCasts() skips * MaterializeTemporaryExpr * CXXBindTemporaryExpr

Declared at: clang/include/clang/AST/Expr.h:846

const clang::Expr* IgnoreImplicit() const

Declared at: clang/include/clang/AST/Expr.h:847

clang::Expr* IgnoreImplicitAsWritten()

Description

Skip past any implicit AST nodes which might surround this expression until reaching a fixed point. Same as IgnoreImplicit, except that it also skips over implicit calls to constructors and conversion functions. FIXME: Should IgnoreImplicit do this?

Declared at: clang/include/clang/AST/Expr.h:856

const clang::Expr* IgnoreImplicitAsWritten() const

Declared at: clang/include/clang/AST/Expr.h:857

clang::Expr* IgnoreParenBaseCasts()

Description

Skip past any parentheses and derived-to-base casts until reaching a fixed point. Skips: * What IgnoreParens() skips * CastExpr which represent a derived-to-base cast (CK_DerivedToBase, CK_UncheckedDerivedToBase and CK_NoOp)

Declared at: clang/include/clang/AST/Expr.h:932

const clang::Expr* IgnoreParenBaseCasts() const

Declared at: clang/include/clang/AST/Expr.h:933

const clang::Expr* IgnoreParenCasts() const

Declared at: clang/include/clang/AST/Expr.h:892

clang::Expr* IgnoreParenCasts()

Description

Skip past any parentheses and casts which might surround this expression until reaching a fixed point. Skips: * What IgnoreParens() skips * What IgnoreCasts() skips

Declared at: clang/include/clang/AST/Expr.h:891

const clang::Expr* IgnoreParenImpCasts() const

Declared at: clang/include/clang/AST/Expr.h:883

clang::Expr* IgnoreParenImpCasts()

Description

Skip past any parentheses and implicit casts which might surround this expression until reaching a fixed point. FIXME: IgnoreParenImpCasts really ought to be equivalent to IgnoreParens() + IgnoreImpCasts() until reaching a fixed point. However this is currently not the case. Instead IgnoreParenImpCasts() skips: * What IgnoreParens() skips * What IgnoreImpCasts() skips * MaterializeTemporaryExpr * SubstNonTypeTemplateParmExpr

Declared at: clang/include/clang/AST/Expr.h:882

const clang::Expr* IgnoreParenLValueCasts() const

Declared at: clang/include/clang/AST/Expr.h:912

clang::Expr* IgnoreParenLValueCasts()

Description

Skip past any parentheses and lvalue casts which might surround this expression until reaching a fixed point. Skips: * What IgnoreParens() skips * What IgnoreCasts() skips, except that only lvalue-to-rvalue casts are skipped FIXME: This is intended purely as a temporary workaround for code that hasn't yet been rewritten to do the right thing about those casts, and may disappear along with the last internal use.

Declared at: clang/include/clang/AST/Expr.h:911

const clang::Expr* IgnoreParenNoopCasts(
    const clang::ASTContext& Ctx) const

Declared at: clang/include/clang/AST/Expr.h:923

Parameters

const clang::ASTContext& Ctx

clang::Expr* IgnoreParenNoopCasts(
    const clang::ASTContext& Ctx)

Description

Skip past any parenthese and casts which do not change the value (including ptr->int casts of the same size) until reaching a fixed point. Skips: * What IgnoreParens() skips * CastExpr which do not change the value * SubstNonTypeTemplateParmExpr

Declared at: clang/include/clang/AST/Expr.h:922

Parameters

const clang::ASTContext& Ctx

const clang::Expr* IgnoreParens() const

Declared at: clang/include/clang/AST/Expr.h:869

clang::Expr* IgnoreParens()

Description

Skip past any parentheses which might surround this expression until reaching a fixed point. Skips: * ParenExpr * UnaryOperator if `UO_Extension` * GenericSelectionExpr if `!isResultDependent()` * ChooseExpr if `!isConditionDependent()` * ConstantExpr

Declared at: clang/include/clang/AST/Expr.h:868

clang::Expr* IgnoreUnlessSpelledInSource()

Description

Skip past any invisble AST nodes which might surround this statement, such as ExprWithCleanups or ImplicitCastExpr nodes, but also injected CXXMemberExpr and CXXConstructExpr which represent implicit conversions.

Declared at: clang/include/clang/AST/Expr.h:816

const clang::Expr* IgnoreUnlessSpelledInSource()
    const

Declared at: clang/include/clang/AST/Expr.h:817

static bool classof(const clang::Stmt* T)

Declared at: clang/include/clang/AST/Expr.h:986

Parameters

const clang::Stmt* T

bool containsErrors() const

Description

Whether this expression contains subexpressions which had errors, e.g. a TypoExpr.

Declared at: clang/include/clang/AST/Expr.h:238

bool containsUnexpandedParameterPack() const

Description

Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates). Given the following function template: The expressions \c args and \c static_cast<Types&&>(args) both contain parameter packs.

Declared at: clang/include/clang/AST/Expr.h:232

static clang::QualType findBoundMemberType(
    const clang::Expr* expr)

Description

Given an expression of bound-member type, find the type of the member. Returns null if this is an *overloaded* bound member expression.

Declared at: clang/include/clang/AST/Expr.h:810

Parameters

const clang::Expr* expr

const clang::ValueDecl*
getAsBuiltinConstantDeclRef(
    const clang::ASTContext& Context) const

Description

If this expression is an unambiguous reference to a single declaration, in the style of __builtin_function_start, return that declaration. Note that this may return a non-static member function or field in C++ if this expression is a member pointer constant.

Declared at: clang/include/clang/AST/Expr.h:579

Parameters

const clang::ASTContext& Context

const clang::CXXRecordDecl*
getBestDynamicClassType() const

Description

For an expression of class type or pointer to class type, return the most derived class decl the expression is known to refer to. If this expression is a cast, this method looks through it to find the most derived decl that can be inferred from the expression. This is valid because derived-to-base conversions have undefined behavior if the object isn't dynamically of the derived type.

Declared at: clang/include/clang/AST/Expr.h:962

const clang::Expr* getBestDynamicClassTypeExpr()
    const

Description

Get the inner expression that determines the best dynamic class. If this is a prvalue, we guarantee that it is of the most-derived type for the object itself.

Declared at: clang/include/clang/AST/Expr.h:967

clang::ExprDependence getDependence() const

Declared at: clang/include/clang/AST/Expr.h:155

clang::SourceLocation getExprLoc() const

Description

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic expression.

Declared at: clang/include/clang/AST/Expr.h:244

clang::FPOptions getFPFeaturesInEffect(
    const clang::LangOptions& LO) const

Description

Returns the set of floating point options that apply to this expression. Only meaningful for operations on floating point values.

Declared at: clang/include/clang/AST/Expr.h:416

Parameters

const clang::LangOptions& LO

Optional<llvm::APSInt> getIntegerConstantExpr(
    const clang::ASTContext& Ctx,
    clang::SourceLocation* Loc = nullptr,
    bool isEvaluated = true) const

Description

isIntegerConstantExpr - Return the value if this expression is a valid integer constant expression. If not a valid i-c-e, return None and fill in Loc (if specified) with the location of the invalid expression. Note: This does not perform the implicit conversions required by C++11 [expr.const]p5.

Declared at: clang/include/clang/AST/Expr.h:532

Parameters

const clang::ASTContext& Ctx
clang::SourceLocation* Loc = nullptr
bool isEvaluated = true

const clang::ObjCPropertyRefExpr*
getObjCProperty() const

Description

If this expression is an l-value for an Objective C property, find the underlying property reference expression.

Declared at: clang/include/clang/AST/Expr.h:484

clang::ExprObjectKind getObjectKind() const

Description

getObjectKind - The object kind that this expression produces. Object kinds are meaningful only for expressions that yield an l-value or x-value.

Declared at: clang/include/clang/AST/Expr.h:437

clang::Decl* getReferencedDeclOfCallee()

Declared at: clang/include/clang/AST/Expr.h:477

const clang::Decl* getReferencedDeclOfCallee()
    const

Declared at: clang/include/clang/AST/Expr.h:478

const clang::FieldDecl* getSourceBitField() const

Declared at: clang/include/clang/AST/Expr.h:473

clang::FieldDecl* getSourceBitField()

Description

If this expression refers to a bit-field, retrieve the declaration of that bit-field. Note that this returns a non-null pointer in subtly different places than refersToBitField returns true. In particular, this can return a non-null pointer even for r-values loaded from bit-fields, but it will return null for a conditional bit-field.

Declared at: clang/include/clang/AST/Expr.h:471

clang::QualType getType() const

Declared at: clang/include/clang/AST/Expr.h:141

clang::ExprValueKind getValueKind() const

Description

getValueKind - The value kind that this expression produces.

Declared at: clang/include/clang/AST/Expr.h:430

static clang::ExprValueKind getValueKindForType(
    clang::QualType T)

Description

getValueKindForType - Given a formal return or parameter type, give its value kind.

Declared at: clang/include/clang/AST/Expr.h:420

Parameters

clang::QualType T

static bool hasAnyTypeDependentArguments(
    ArrayRef<clang::Expr*> Exprs)

Declared at: clang/include/clang/AST/Expr.h:953

Parameters

ArrayRef<clang::Expr*> Exprs

bool hasNonTrivialCall(
    const clang::ASTContext& Ctx) const

Description

Determine whether this expression involves a call to any function that is not trivial.

Declared at: clang/include/clang/AST/Expr.h:680

Parameters

const clang::ASTContext& Ctx

bool hasPlaceholderType() const

Description

Returns whether this expression has a placeholder type.

Declared at: clang/include/clang/AST/Expr.h:502

bool hasPlaceholderType(BuiltinType::Kind K) const

Description

Returns whether this expression has a specific placeholder type.

Declared at: clang/include/clang/AST/Expr.h:507

Parameters

BuiltinType::Kind K

bool isBoundMemberFunction(
    clang::ASTContext& Ctx) const

Description

Returns true if this expression is a bound member function.

Declared at: clang/include/clang/AST/Expr.h:805

Parameters

clang::ASTContext& Ctx

bool isCXX11ConstantExpr(
    const clang::ASTContext& Ctx,
    clang::APValue* Result = nullptr,
    clang::SourceLocation* Loc = nullptr) const

Description

isCXX11ConstantExpr - Return true if this expression is a constant expression in C++11. Can only be used in C++. Note: This does not perform the implicit conversions required by C++11 [expr.const]p5.

Declared at: clang/include/clang/AST/Expr.h:547

Parameters

const clang::ASTContext& Ctx
clang::APValue* Result = nullptr
clang::SourceLocation* Loc = nullptr

bool isCXX98IntegralConstantExpr(
    const clang::ASTContext& Ctx) const

Description

isCXX98IntegralConstantExpr - Return true if this expression is an integral constant expression in C++98. Can only be used in C++.

Declared at: clang/include/clang/AST/Expr.h:540

Parameters

const clang::ASTContext& Ctx

bool isConstantInitializer(
    clang::ASTContext& Ctx,
    bool ForRef,
    const clang::Expr** Culprit = nullptr) const

Description

isConstantInitializer - Returns true if this expression can be emitted to IR as a constant, and thus can be used as a constant initializer in C. If this expression is not constant and Culprit is non-null, it is used to store the address of first non constant expr.

Declared at: clang/include/clang/AST/Expr.h:572

Parameters

clang::ASTContext& Ctx
bool ForRef
const clang::Expr** Culprit = nullptr

bool isDefaultArgument() const

Description

Determine whether this expression is a default function argument. Default arguments are implicitly generated in the abstract syntax tree by semantic analysis for function calls, object constructions, etc. in C++. Default arguments are represented by \c CXXDefaultArgExpr nodes; this routine also looks through any implicit casts to determine whether the expression is a default argument.

Declared at: clang/include/clang/AST/Expr.h:944

bool isEvaluatable(const clang::ASTContext& Ctx,
                   clang::Expr::SideEffectsKind
                       AllowSideEffects =
                           SE_NoSideEffects) const

Description

isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-effects, but discard the result.

Declared at: clang/include/clang/AST/Expr.h:665

Parameters

const clang::ASTContext& Ctx
clang::Expr::SideEffectsKind AllowSideEffects = SE_NoSideEffects

bool isGLValue() const

Declared at: clang/include/clang/AST/Expr.h:273

bool isImplicitCXXThis() const

Description

Whether this expression is an implicit reference to 'this' in C++.

Declared at: clang/include/clang/AST/Expr.h:951

bool isInstantiationDependent() const

Description

Whether this expression is instantiation-dependent, meaning that it depends in some way on - a template parameter (even if neither its type nor (constant) value can change due to the template instantiation) - or an error In the following example, the expression \c sizeof(sizeof(T() + T())) is instantiation-dependent (since it involves a template parameter \c T), but is neither type- nor value-dependent, since the type of the inner\c sizeof is known (\c std::size_t) and therefore the size of the outer\c sizeof is known.

Declared at: clang/include/clang/AST/Expr.h:214

bool isIntegerConstantExpr(
    const clang::ASTContext& Ctx,
    clang::SourceLocation* Loc = nullptr) const

Declared at: clang/include/clang/AST/Expr.h:535

Parameters

const clang::ASTContext& Ctx
clang::SourceLocation* Loc = nullptr

bool isKnownToHaveBooleanValue(
    bool Semantic = true) const

Description

isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or 1. This happens for _Bool/bool expressions but also int expressions which are produced by things like comparisons in C.

Declared at: clang/include/clang/AST/Expr.h:524

Parameters

bool Semantic = true
If true, only return true for expressions that are known to be semantically boolean, which might not be true even for expressions that are known to evaluate to 0/1. For instance, reading an unsigned bit-field with width '1' will evaluate to 0/1, but doesn't necessarily semantically correspond to a bool.

bool isLValue() const

Description

isLValue - True if this expression is an "l-value" according to the rules of the current language. C and C++ give somewhat different rules for this concept, but in general, the result of an l-value expression identifies a specific object whereas the result of an r-value expression is a value detached from any specific storage. C++11 divides the concept of "r-value" into pure r-values ("pr-values") and so-called expiring values ("x-values"), which identify specific objects that can be safely cannibalized for their resources.

Declared at: clang/include/clang/AST/Expr.h:270

clang::Expr::isModifiableLvalueResult
isModifiableLvalue(
    clang::ASTContext& Ctx,
    clang::SourceLocation* Loc = nullptr) const

Description

isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplete type, does not have a const-qualified type, and if it is a structure or union, does not have any member (including, recursively, any member or element of all contained aggregates or unions) with a const-qualified type.

Declared at: clang/include/clang/AST/Expr.h:319

Parameters

clang::ASTContext& Ctx
clang::SourceLocation* Loc = nullptr
[in,out] - A source location which *may* be filled in with the location of the expression making this a non-modifiable lvalue, if specified.

clang::Expr::NullPointerConstantKind
isNullPointerConstant(
    clang::ASTContext& Ctx,
    clang::Expr::
        NullPointerConstantValueDependence NPC)
    const

Description

isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant. The return value can further distinguish the kind of NULL pointer constant that was detected.

Declared at: clang/include/clang/AST/Expr.h:796

Parameters

clang::ASTContext& Ctx
clang::Expr::NullPointerConstantValueDependence NPC

bool isOBJCGCCandidate(
    clang::ASTContext& Ctx) const

Description

isOBJCGCCandidate - Return true if this expression may be used in a read/ write barrier.

Declared at: clang/include/clang/AST/Expr.h:802

Parameters

clang::ASTContext& Ctx

bool isObjCSelfExpr() const

Description

Check if this expression is the ObjC 'self' implicit parameter.

Declared at: clang/include/clang/AST/Expr.h:487

bool isOrdinaryOrBitFieldObject() const

Declared at: clang/include/clang/AST/Expr.h:441

bool isPRValue() const

Declared at: clang/include/clang/AST/Expr.h:271

static bool isPotentialConstantExpr(
    const clang::FunctionDecl* FD,
    SmallVectorImpl<clang::PartialDiagnosticAt>&
        Diags)

Description

isPotentialConstantExpr - Return true if this function's definition might be usable in a constant expression in C++11, if it were marked constexpr. Return false if the function can never produce a constant expression, along with diagnostics describing why not.

Declared at: clang/include/clang/AST/Expr.h:554

Parameters

const clang::FunctionDecl* FD
SmallVectorImpl<clang::PartialDiagnosticAt>& Diags

static bool isPotentialConstantExprUnevaluated(
    clang::Expr* E,
    const clang::FunctionDecl* FD,
    SmallVectorImpl<clang::PartialDiagnosticAt>&
        Diags)

Description

isPotentialConstantExprUnevaluted - Return true if this expression might be usable in a constant expression in C++11 in an unevaluated context, if it were in function FD marked constexpr. Return false if the function can never produce a constant expression, along with diagnostics describing why not.

Declared at: clang/include/clang/AST/Expr.h:563

Parameters

clang::Expr* E
const clang::FunctionDecl* FD
SmallVectorImpl<clang::PartialDiagnosticAt>& Diags

bool isReadIfDiscardedInCPlusPlus11() const

Description

Determine whether an lvalue-to-rvalue conversion should implicitly be applied to this expression if it appears as a discarded-value expression in C++11 onwards. This applies to certain forms of volatile glvalues.

Declared at: clang/include/clang/AST/Expr.h:249

static bool isSameComparisonOperand(
    const clang::Expr* E1,
    const clang::Expr* E2)

Description

Checks that the two Expr's will refer to the same value as a comparison operand. The caller must ensure that the values referenced by the Expr's are not modified between E1 and E2 or the result my be invalid.

Declared at: clang/include/clang/AST/Expr.h:984

Parameters

const clang::Expr* E1
const clang::Expr* E2

bool isTemporaryObject(
    clang::ASTContext& Ctx,
    const clang::CXXRecordDecl* TempTy) const

Description

Determine whether the result of this expression is a temporary object of the given class type.

Declared at: clang/include/clang/AST/Expr.h:948

Parameters

clang::ASTContext& Ctx
const clang::CXXRecordDecl* TempTy

bool isTypeDependent() const

Description

Determines whether the type of this expression depends on - a template paramter (C++ [temp.dep.expr], which means that its type could change from one template instantiation to the next) - or an error For example, the expressions "x" and "x + y" are type-dependent in the following code, but "y" is not type-dependent:

Declared at: clang/include/clang/AST/Expr.h:185

bool isUnusedResultAWarning(
    const clang::Expr*& WarnExpr,
    clang::SourceLocation& Loc,
    clang::SourceRange& R1,
    clang::SourceRange& R2,
    clang::ASTContext& Ctx) const

Description

isUnusedResultAWarning - Return true if this immediate expression should be warned about if the result is unused. If so, fill in expr, location, and ranges with expr to warn on and source locations/ranges appropriate for a warning.

Declared at: clang/include/clang/AST/Expr.h:255

Parameters

const clang::Expr*& WarnExpr
clang::SourceLocation& Loc
clang::SourceRange& R1
clang::SourceRange& R2
clang::ASTContext& Ctx

bool isValueDependent() const

Description

Determines whether the value of this expression depends on - a template parameter (C++ [temp.dep.constexpr]) - or an error, whose resolution is unknown For example, the array bound of "Chars" in the following example is value-dependent.

Declared at: clang/include/clang/AST/Expr.h:168

bool isXValue() const

Declared at: clang/include/clang/AST/Expr.h:272

bool refersToBitField() const

Description

Returns true if this expression is a gl-value that potentially refers to a bit-field. In C++, whether a gl-value refers to a bitfield is essentially an aspect of the value-kind type system.

Declared at: clang/include/clang/AST/Expr.h:462

bool refersToGlobalRegisterVar() const

Description

Returns whether this expression refers to a global register variable.

Declared at: clang/include/clang/AST/Expr.h:499

bool refersToMatrixElement() const

Description

Returns whether this expression refers to a matrix element.

Declared at: clang/include/clang/AST/Expr.h:493

bool refersToVectorElement() const

Description

Returns whether this expression refers to a vector element.

Declared at: clang/include/clang/AST/Expr.h:490

void setDependence(clang::ExprDependence Deps)

Description

Each concrete expr subclass is expected to compute its dependence and call this in the constructor.

Declared at: clang/include/clang/AST/Expr.h:134

Parameters

clang::ExprDependence Deps

void setObjectKind(clang::ExprObjectKind Cat)

Description

setObjectKind - Set the object kind produced by this expression.

Declared at: clang/include/clang/AST/Expr.h:450

Parameters

clang::ExprObjectKind Cat

void setType(clang::QualType t)

Declared at: clang/include/clang/AST/Expr.h:142

Parameters

clang::QualType t

void setValueKind(clang::ExprValueKind Cat)

Description

setValueKind - Set the value kind produced by this expression.

Declared at: clang/include/clang/AST/Expr.h:447

Parameters

clang::ExprValueKind Cat

const clang::Expr* skipRValueSubobjectAdjustments(
    SmallVectorImpl<const clang::Expr*>& CommaLHS,
    SmallVectorImpl<clang::SubobjectAdjustment>&
        Adjustments) const

Description

Walk outwards from an expression we want to bind a reference to and find the expression whose lifetime needs to be extended. Record the LHSs of comma expressions and adjustments needed along the path.

Declared at: clang/include/clang/AST/Expr.h:972

Parameters

SmallVectorImpl<const clang::Expr*>& CommaLHS
SmallVectorImpl<clang::SubobjectAdjustment>& Adjustments

const clang::Expr*
skipRValueSubobjectAdjustments() const

Declared at: clang/include/clang/AST/Expr.h:975

bool tryEvaluateObjectSize(
    uint64_t& Result,
    clang::ASTContext& Ctx,
    unsigned int Type) const

Description

If the current Expr is a pointer, this will try to statically determine the number of bytes available where the pointer is pointing. Returns true if all of the above holds and we were able to figure out the size, false otherwise.

Declared at: clang/include/clang/AST/Expr.h:746

Parameters

uint64_t& Result
clang::ASTContext& Ctx
unsigned int Type
- How to evaluate the size of the Expr, as defined by the "type" parameter of __builtin_object_size

bool tryEvaluateStrLen(
    uint64_t& Result,
    clang::ASTContext& Ctx) const

Description

If the current Expr is a pointer, this will try to statically determine the strlen of the string pointed to. Returns true if all of the above holds and we were able to figure out the strlen, false otherwise.

Declared at: clang/include/clang/AST/Expr.h:753

Parameters

uint64_t& Result
clang::ASTContext& Ctx