diff options
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
-rw-r--r-- | clang/lib/AST/Expr.cpp | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 193efa4e097..dd1996df668 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -137,9 +137,9 @@ bool Expr::isKnownToHaveBooleanValue() const { // If this value has _Bool type, it is obvious 0/1. if (E->getType()->isBooleanType()) return true; - // If this is a non-scalar-integer type, we don't care enough to try. + // If this is a non-scalar-integer type, we don't care enough to try. if (!E->getType()->isIntegralOrEnumerationType()) return false; - + if (const UnaryOperator *UO = dyn_cast<UnaryOperator>(E)) { switch (UO->getOpcode()) { case UO_Plus: @@ -150,12 +150,12 @@ bool Expr::isKnownToHaveBooleanValue() const { return false; } } - + // Only look through implicit casts. If the user writes // '(int) (a && b)' treat it as an arbitrary int. if (const ImplicitCastExpr *CE = dyn_cast<ImplicitCastExpr>(E)) return CE->getSubExpr()->isKnownToHaveBooleanValue(); - + if (const BinaryOperator *BO = dyn_cast<BinaryOperator>(E)) { switch (BO->getOpcode()) { default: return false; @@ -168,24 +168,24 @@ bool Expr::isKnownToHaveBooleanValue() const { case BO_LAnd: // AND operator. case BO_LOr: // Logical OR operator. return true; - + case BO_And: // Bitwise AND operator. case BO_Xor: // Bitwise XOR operator. case BO_Or: // Bitwise OR operator. // Handle things like (x==2)|(y==12). return BO->getLHS()->isKnownToHaveBooleanValue() && BO->getRHS()->isKnownToHaveBooleanValue(); - + case BO_Comma: case BO_Assign: return BO->getRHS()->isKnownToHaveBooleanValue(); } } - + if (const ConditionalOperator *CO = dyn_cast<ConditionalOperator>(E)) return CO->getTrueExpr()->isKnownToHaveBooleanValue() && CO->getFalseExpr()->isKnownToHaveBooleanValue(); - + return false; } @@ -230,7 +230,7 @@ SourceLocation Expr::getExprLoc() const { // Primary Expressions. //===----------------------------------------------------------------------===// -/// Compute the type-, value-, and instantiation-dependence of a +/// Compute the type-, value-, and instantiation-dependence of a /// declaration reference /// based on the declaration being referenced. static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, @@ -259,9 +259,9 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, } else if (T->isInstantiationDependentType()) { InstantiationDependent = true; } - + // (TD) - a conversion-function-id that specifies a dependent type - if (D->getDeclName().getNameKind() + if (D->getDeclName().getNameKind() == DeclarationName::CXXConversionFunctionName) { QualType T = D->getDeclName().getCXXNameType(); if (T->isDependentType()) { @@ -270,18 +270,18 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, InstantiationDependent = true; return; } - + if (T->isInstantiationDependentType()) InstantiationDependent = true; } - + // (VD) - the name of a non-type template parameter, if (isa<NonTypeTemplateParmDecl>(D)) { ValueDependent = true; InstantiationDependent = true; return; } - + // (VD) - a constant with integral or enumeration type and is // initialized with an expression that is value-dependent. // (VD) - a constant with literal type and is initialized with an @@ -302,10 +302,10 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, } } - // (VD) - FIXME: Missing from the standard: - // - a member function or a static data member of the current + // (VD) - FIXME: Missing from the standard: + // - a member function or a static data member of the current // instantiation - if (Var->isStaticDataMember() && + if (Var->isStaticDataMember() && Var->getDeclContext()->isDependentContext()) { ValueDependent = true; InstantiationDependent = true; @@ -313,12 +313,12 @@ static void computeDeclRefDependence(const ASTContext &Ctx, NamedDecl *D, if (TInfo->getType()->isIncompleteArrayType()) TypeDependent = true; } - + return; } - - // (VD) - FIXME: Missing from the standard: - // - a member function or a static data member of the current + + // (VD) - FIXME: Missing from the standard: + // - a member function or a static data member of the current // instantiation if (isa<CXXMethodDecl>(D) && D->getDeclContext()->isDependentContext()) { ValueDependent = true; @@ -625,7 +625,7 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { llvm::raw_string_ostream TOut(TemplateParams); for (SpecsTy::reverse_iterator I = Specs.rbegin(), E = Specs.rend(); I != E; ++I) { - const TemplateParameterList *Params + const TemplateParameterList *Params = (*I)->getSpecializedTemplate()->getTemplateParameters(); const TemplateArgumentList &Args = (*I)->getTemplateArgs(); assert(Params->size() == Args.size()); @@ -638,10 +638,10 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { } } - FunctionTemplateSpecializationInfo *FSI + FunctionTemplateSpecializationInfo *FSI = FD->getTemplateSpecializationInfo(); if (FSI && !FSI->isExplicitSpecialization()) { - const TemplateParameterList* Params + const TemplateParameterList* Params = FSI->getTemplate()->getTemplateParameters(); const TemplateArgumentList* Args = FSI->TemplateArguments; assert(Params->size() == Args->size()); @@ -942,7 +942,7 @@ void StringLiteral::outputString(raw_ostream &OS) const { // Convert UTF-16 surrogate pairs back to codepoints before rendering. // Leave invalid surrogates alone; we'll use \x for those. - if (getKind() == UTF16 && I != N - 1 && Char >= 0xd800 && + if (getKind() == UTF16 && I != N - 1 && Char >= 0xd800 && Char <= 0xdbff) { uint32_t Trail = getCodeUnit(I + 1); if (Trail >= 0xdc00 && Trail <= 0xdfff) { @@ -1025,7 +1025,7 @@ void StringLiteral::setString(const ASTContext &C, StringRef Str, // code unit size and endianness for the type of string. this->Kind = Kind; this->IsPascal = IsPascal; - + CharByteWidth = mapCharByteWidth(C.getTargetInfo(),Kind); assert((Str.size()%CharByteWidth == 0) && "size of data must be multiple of CharByteWidth"); @@ -1092,7 +1092,7 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM, while (1) { assert(TokNo < getNumConcatenated() && "Invalid byte number!"); SourceLocation StrTokLoc = getStrTokenLoc(TokNo); - + // Get the spelling of the string so that we can get the data that makes up // the string literal, not the identifier for the macro it is potentially // expanded through. @@ -1112,17 +1112,17 @@ StringLiteral::getLocationOfByte(unsigned ByteNo, const SourceManager &SM, } const char *StrData = Buffer.data()+LocInfo.second; - + // Create a lexer starting at the beginning of this token. Lexer TheLexer(SM.getLocForStartOfFile(LocInfo.first), Features, Buffer.begin(), StrData, Buffer.end()); Token TheTok; TheLexer.LexFromRawLexer(TheTok); - + // Use the StringLiteralParser to compute the length of the string in bytes. StringLiteralParser SLP(TheTok, SM, Features, Target); unsigned TokNumBytes = SLP.GetStringLength(); - + // If the byte is in this token, return the location of the byte. if (ByteNo < TokNumBytes || (ByteNo == TokNumBytes && TokNo == getNumConcatenated() - 1)) { @@ -1258,12 +1258,12 @@ Decl *CallExpr::getCalleeDecl() { Decl *Expr::getReferencedDeclOfCallee() { Expr *CEE = IgnoreParenImpCasts(); - + while (SubstNonTypeTemplateParmExpr *NTTP = dyn_cast<SubstNonTypeTemplateParmExpr>(CEE)) { CEE = NTTP->getReplacement()->IgnoreParenCasts(); } - + // If we're calling a dereference, look at the pointer instead. if (BinaryOperator *BO = dyn_cast<BinaryOperator>(CEE)) { if (BO->isPtrMemOp()) @@ -1379,7 +1379,7 @@ SourceLocation CallExpr::getLocEnd() const { OffsetOfExpr *OffsetOfExpr::Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, - TypeSourceInfo *tsi, + TypeSourceInfo *tsi, ArrayRef<OffsetOfNode> comps, ArrayRef<Expr*> exprs, SourceLocation RParenLoc) { @@ -1402,17 +1402,17 @@ OffsetOfExpr::OffsetOfExpr(const ASTContext &C, QualType type, ArrayRef<OffsetOfNode> comps, ArrayRef<Expr*> exprs, SourceLocation RParenLoc) : Expr(OffsetOfExprClass, type, VK_RValue, OK_Ordinary, - /*TypeDependent=*/false, + /*TypeDependent=*/false, /*ValueDependent=*/tsi->getType()->isDependentType(), tsi->getType()->isInstantiationDependentType(), tsi->getType()->containsUnexpandedParameterPack()), - OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), + OperatorLoc(OperatorLoc), RParenLoc(RParenLoc), TSInfo(tsi), NumComps(comps.size()), NumExprs(exprs.size()) { for (unsigned i = 0; i != comps.size(); ++i) { setComponent(i, comps[i]); } - + for (unsigned i = 0; i != exprs.size(); ++i) { if (exprs[i]->isTypeDependent() || exprs[i]->isValueDependent()) ExprBits.ValueDependent = true; @@ -1427,7 +1427,7 @@ IdentifierInfo *OffsetOfNode::getFieldName() const { assert(getKind() == Field || getKind() == Identifier); if (getKind() == Field) return getField()->getIdentifier(); - + return reinterpret_cast<IdentifierInfo *> (Data & ~(uintptr_t)Mask); } @@ -1497,11 +1497,11 @@ MemberExpr *MemberExpr::Create( E->setValueDependent(true); E->setTypeDependent(true); E->setInstantiationDependent(true); - } - else if (QualifierLoc && - QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) + } + else if (QualifierLoc && + QualifierLoc.getNestedNameSpecifier()->isInstantiationDependent()) E->setInstantiationDependent(true); - + E->HasQualifierOrFoundDecl = true; MemberExprNameQualifier *NQ = @@ -1582,9 +1582,9 @@ bool CastExpr::CastConsistency() const { // Otherwise, we should only have block and ObjC pointer casts // here if they stay within the type kind. if (!getType()->isPointerType()) { - assert(getType()->isObjCObjectPointerType() == + assert(getType()->isObjCObjectPointerType() == getSubExpr()->getType()->isObjCObjectPointerType()); - assert(getType()->isBlockPointerType() == + assert(getType()->isBlockPointerType() == getSubExpr()->getType()->isBlockPointerType()); } goto CheckNoBasePath; @@ -1708,11 +1708,11 @@ Expr *CastExpr::getSubExprAsWritten() { if (auto *MCE = dyn_cast<CXXMemberCallExpr>(SubExpr)) SubExpr = MCE->getImplicitObjectArgument(); } - + // If the subexpression we're left with is an implicit cast, look // through that, too. - } while ((E = dyn_cast<ImplicitCastExpr>(SubExpr))); - + } while ((E = dyn_cast<ImplicitCastExpr>(SubExpr))); + return const_cast<Expr*>(SubExpr); } @@ -1933,7 +1933,7 @@ InitListExpr::InitListExpr(const ASTContext &C, SourceLocation lbraceloc, if (initExprs[I]->containsUnexpandedParameterPack()) ExprBits.ContainsUnexpandedParameterPack = true; } - + InitExprs.insert(C, InitExprs.end(), initExprs.begin(), initExprs.end()); } @@ -2023,12 +2023,12 @@ SourceLocation InitListExpr::getLocStart() const { if (Beg.isInvalid()) { // Find the first non-null initializer. for (InitExprsTy::const_iterator I = InitExprs.begin(), - E = InitExprs.end(); + E = InitExprs.end(); I != E; ++I) { if (Stmt *S = *I) { Beg = S->getLocStart(); break; - } + } } } return Beg; @@ -2079,7 +2079,7 @@ Stmt *BlockExpr::getBody() { /// be warned about if the result is unused. If so, fill in Loc and Ranges /// with location to warn on and the source range[s] to report with the /// warning. -bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, +bool Expr::isUnusedResultAWarning(const Expr *&WarnE, SourceLocation &Loc, SourceRange &R1, SourceRange &R2, ASTContext &Ctx) const { // Don't warn if the expr is type dependent. The type could end up @@ -2436,7 +2436,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const { return cast<CStyleCastExpr>(E)->getSubExpr()->isOBJCGCCandidate(Ctx); case DeclRefExprClass: { const Decl *D = cast<DeclRefExpr>(E)->getDecl(); - + if (const VarDecl *VD = dyn_cast<VarDecl>(D)) { if (VD->hasGlobalStorage()) return true; @@ -2526,7 +2526,7 @@ Expr *Expr::IgnoreParenCasts() { E = P->getSubExpr(); continue; } - if (MaterializeTemporaryExpr *Materialize + if (MaterializeTemporaryExpr *Materialize = dyn_cast<MaterializeTemporaryExpr>(E)) { E = Materialize->GetTemporaryExpr(); continue; @@ -2535,7 +2535,7 @@ Expr *Expr::IgnoreParenCasts() { = dyn_cast<SubstNonTypeTemplateParmExpr>(E)) { E = NTTP->getReplacement(); continue; - } + } return E; } } @@ -2574,7 +2574,7 @@ Expr *Expr::IgnoreParenLValueCasts() { E = P->getSubExpr(); continue; } - } else if (MaterializeTemporaryExpr *Materialize + } else if (MaterializeTemporaryExpr *Materialize = dyn_cast<MaterializeTemporaryExpr>(E)) { E = Materialize->GetTemporaryExpr(); continue; @@ -2613,7 +2613,7 @@ Expr *Expr::IgnoreParenImpCasts() { E = P->getSubExpr(); continue; } - if (MaterializeTemporaryExpr *Materialize + if (MaterializeTemporaryExpr *Materialize = dyn_cast<MaterializeTemporaryExpr>(E)) { E = Materialize->GetTemporaryExpr(); continue; @@ -2668,7 +2668,7 @@ Expr *Expr::IgnoreParenNoopCasts(ASTContext &Ctx) { E = NTTP->getReplacement(); continue; } - + return E; } } @@ -2680,7 +2680,7 @@ bool Expr::isDefaultArgument() const { while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) E = ICE->getSubExprAsWritten(); - + return isa<CXXDefaultArgExpr>(E); } @@ -2756,43 +2756,43 @@ bool Expr::isTemporaryObject(ASTContext &C, const CXXRecordDecl *TempTy) const { bool Expr::isImplicitCXXThis() const { const Expr *E = this; - + // Strip away parentheses and casts we don't care about. while (true) { if (const ParenExpr *Paren = dyn_cast<ParenExpr>(E)) { E = Paren->getSubExpr(); continue; } - + if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { if (ICE->getCastKind() == CK_NoOp || ICE->getCastKind() == CK_LValueToRValue || - ICE->getCastKind() == CK_DerivedToBase || + ICE->getCastKind() == CK_DerivedToBase || ICE->getCastKind() == CK_UncheckedDerivedToBase) { E = ICE->getSubExpr(); continue; } } - + if (const UnaryOperator* UnOp = dyn_cast<UnaryOperator>(E)) { if (UnOp->getOpcode() == UO_Extension) { E = UnOp->getSubExpr(); continue; } } - + if (const MaterializeTemporaryExpr *M = dyn_cast<MaterializeTemporaryExpr>(E)) { E = M->GetTemporaryExpr(); continue; } - + break; } - + if (const CXXThisExpr *This = dyn_cast<CXXThisExpr>(E)) return This->isImplicit(); - + return false; } @@ -2978,7 +2978,7 @@ bool CallExpr::isBuiltinAssumeFalse(const ASTContext &Ctx) const { if (!FD || (FD->getBuiltinID() != Builtin::BI__assume && FD->getBuiltinID() != Builtin::BI__builtin_assume)) return false; - + const Expr* Arg = getArg(0); bool ArgVal; return !Arg->isValueDependent() && @@ -3289,11 +3289,11 @@ namespace { typedef ConstEvaluatedExprVisitor<NonTrivialCallFinder> Inherited; bool NonTrivial; - + public: explicit NonTrivialCallFinder(const ASTContext &Context) : Inherited(Context), NonTrivial(false) { } - + bool hasNonTrivialCall() const { return NonTrivial; } void VisitCallExpr(const CallExpr *E) { @@ -3305,7 +3305,7 @@ namespace { return; } } - + NonTrivial = true; } @@ -3315,7 +3315,7 @@ namespace { Inherited::VisitStmt(E); return; } - + NonTrivial = true; } @@ -3324,7 +3324,7 @@ namespace { Inherited::VisitStmt(E); return; } - + NonTrivial = true; } }; @@ -3333,10 +3333,10 @@ namespace { bool Expr::hasNonTrivialCall(const ASTContext &Ctx) const { NonTrivialCallFinder Finder(Ctx); Finder.Visit(this); - return Finder.hasNonTrivialCall(); + return Finder.hasNonTrivialCall(); } -/// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null +/// isNullPointerConstant - C99 6.3.2.3p3 - Return whether this is a null /// pointer constant or not, as well as the specific kind of constant detected. /// Null pointer constants can be integer constant expressions with the /// value zero, casts of zero to void*, nullptr (C++0X), or __null @@ -3354,7 +3354,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx, return NPCK_ZeroExpression; else return NPCK_NotNull; - + case NPC_ValueDependentIsNotNull: return NPCK_NotNull; } @@ -3410,7 +3410,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx, } else if (isa<GNUNullExpr>(this)) { // The GNU __null extension is always a null pointer constant. return NPCK_GNUNull; - } else if (const MaterializeTemporaryExpr *M + } else if (const MaterializeTemporaryExpr *M = dyn_cast<MaterializeTemporaryExpr>(this)) { return M->GetTemporaryExpr()->isNullPointerConstant(Ctx, NPC); } else if (const OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(this)) { @@ -3431,7 +3431,7 @@ Expr::isNullPointerConstant(ASTContext &Ctx, return ILE->getInit(0)->isNullPointerConstant(Ctx, NPC); } // This expression must be an integer type. - if (!getType()->isIntegerType() || + if (!getType()->isIntegerType() || (Ctx.getLangOpts().CPlusPlus && getType()->isEnumeralType())) return NPCK_NotNull; @@ -3549,7 +3549,7 @@ FieldDecl *Expr::getSourceBitField() { bool Expr::refersToVectorElement() const { // FIXME: Why do we not just look at the ObjectKind here? const Expr *E = this->IgnoreParens(); - + while (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(E)) { if (ICE->getValueKind() != VK_RValue && ICE->getCastKind() == CK_NoOp) @@ -3557,7 +3557,7 @@ bool Expr::refersToVectorElement() const { else break; } - + if (const ArraySubscriptExpr *ASE = dyn_cast<ArraySubscriptExpr>(E)) return ASE->getBase()->getType()->isVectorType(); @@ -3652,7 +3652,7 @@ void ExtVectorElementExpr::getEncodedElementAccess( ShuffleVectorExpr::ShuffleVectorExpr(const ASTContext &C, ArrayRef<Expr*> args, QualType Type, SourceLocation BLoc, - SourceLocation RP) + SourceLocation RP) : Expr(ShuffleVectorExprClass, Type, VK_RValue, OK_Ordinary, Type->isDependentType(), Type->isDependentType(), Type->isInstantiationDependentType(), @@ -3791,11 +3791,11 @@ DesignatedInitExpr::DesignatedInitExpr(const ASTContext &C, QualType Ty, End->isTypeDependent() || End->isValueDependent()) { ExprBits.TypeDependent = ExprBits.ValueDependent = true; ExprBits.InstantiationDependent = true; - } else if (Start->isInstantiationDependent() || + } else if (Start->isInstantiationDependent() || End->isInstantiationDependent()) { ExprBits.InstantiationDependent = true; } - + // Propagate unexpanded parameter packs. if (Start->containsUnexpandedParameterPack() || End->containsUnexpandedParameterPack()) |