clang: lib/Sema/SemaStmt.cpp File Reference (original) (raw)
Go to the source code of this file.
Namespaces | |
---|---|
namespace | llvm |
Diagnostic wrappers for TextAPI types for error reporting. | |
Functions | |
---|---|
static bool | DiagnoseUnusedComparison (Sema &S, const Expr *E) |
Diagnose unused comparisons, both builtin and overloaded operators. | |
static bool | DiagnoseNoDiscard (Sema &S, const NamedDecl *OffendingDecl, const WarnUnusedResultAttr *A, SourceLocation Loc, SourceRange R1, SourceRange R2, bool IsCtor) |
static bool | CmpCaseVals (const std::pair< llvm::APSInt, CaseStmt * > &lhs, const std::pair< llvm::APSInt, CaseStmt * > &rhs) |
CmpCaseVals - Comparison predicate for sorting case values. | |
static bool | CmpEnumVals (const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs) |
CmpEnumVals - Comparison predicate for sorting enumeration values. | |
static bool | EqEnumVals (const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs) |
EqEnumVals - Comparison preficate for uniqing enumeration values. | |
static QualType | GetTypeBeforeIntegralPromotion (const Expr *&E) |
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expression expr. | |
static void | AdjustAPSInt (llvm::APSInt &Val, unsigned BitWidth, bool IsSigned) |
static void | checkCaseValue (Sema &S, SourceLocation Loc, const llvm::APSInt &Val, unsigned UnpromotedWidth, bool UnpromotedSign) |
Check the specified case value is in range for the given unpromoted switch type. | |
static bool | ShouldDiagnoseSwitchCaseNotInEnum (const Sema &S, const EnumDecl *ED, const Expr *CaseExpr, EnumValsTy::iterator &EI, EnumValsTy::iterator &EIEnd, const llvm::APSInt &Val) |
Returns true if we should emit a diagnostic about this case expression not being a part of the enum used in the switch controlling expression. | |
static void | checkEnumTypesInSwitchStmt (Sema &S, const Expr *Cond, const Expr *Case) |
static bool | FinishForRangeVarDecl (Sema &SemaRef, VarDecl *Decl, Expr *Init, SourceLocation Loc, int DiagID) |
Finish building a variable declaration for a for-range statement. | |
static bool | ObjCEnumerationCollection (Expr *Collection) |
static Sema::ForRangeStatus | BuildNonArrayForRange (Sema &SemaRef, Expr *BeginRange, Expr *EndRange, QualType RangeType, VarDecl *BeginVar, VarDecl *EndVar, SourceLocation ColonLoc, SourceLocation CoawaitLoc, OverloadCandidateSet *CandidateSet, ExprResult *BeginExpr, ExprResult *EndExpr, BeginEndFunction *BEF) |
Create the initialization, compare, and increment steps for the range-based for loop expression. | |
static StmtResult | RebuildForRangeWithDereference (Sema &SemaRef, Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *InitStmt, Stmt *LoopVarDecl, SourceLocation ColonLoc, Expr *Range, SourceLocation RangeLoc, SourceLocation RParenLoc) |
Speculatively attempt to dereference an invalid range expression. | |
static void | DiagnoseForRangeReferenceVariableCopies (Sema &SemaRef, const VarDecl *VD, QualType RangeInitType) |
static bool | hasTrivialABIAttr (QualType VariableType) |
Determines whether the VariableType's declaration is a record with the clang::trivial_abi attribute. | |
static void | DiagnoseForRangeConstVariableCopies (Sema &SemaRef, const VarDecl *VD) |
static void | DiagnoseForRangeVariableCopies (Sema &SemaRef, const CXXForRangeStmt *ForStmt) |
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them. | |
static void | CheckJumpOutOfSEHFinally (Sema &S, SourceLocation Loc, const Scope &DestScope) |
static bool | VerifyInitializationSequenceCXX98 (const Sema &S, const InitializationSequence &Seq) |
Verify that the initialization sequence that was picked for the first overload resolution is permissible under C++98. | |
static bool | hasDeducedReturnType (FunctionDecl *FD) |
Determine whether the declared return type of the specified function contains 'auto'. | |
static bool | CheckSimplerImplicitMovesMSVCWorkaround (const Sema &S, const Expr *E) |
static bool | buildCapturedStmtCaptureList (Sema &S, CapturedRegionScopeInfo *RSI, SmallVectorImpl< CapturedStmt::Capture > &Captures, SmallVectorImpl< Expr * > &CaptureInits) |
◆ EnumValsTy
◆ AdjustAPSInt()
◆ buildCapturedStmtCaptureList()
Definition at line 4529 of file SemaStmt.cpp.
References clang::Sema::BuildCaptureField(), clang::Sema::BuildCaptureInit(), clang::sema::CapturedRegionScopeInfo::CapRegionKind, clang::sema::CapturingScopeInfo::Captures, clang::CR_OpenMP, clang::Sema::getLangOpts(), clang::sema::Capture::getLocation(), clang::sema::Capture::getVariable(), clang::Init, clang::sema::Capture::isInvalid(), clang::sema::Capture::isReferenceCapture(), clang::sema::Capture::isThisCapture(), clang::sema::Capture::isVariableCapture(), clang::sema::Capture::isVLATypeCapture(), clang::Sema::OpenMP(), clang::sema::CapturedRegionScopeInfo::OpenMPLevel, clang::SemaOpenMP::setOpenMPCaptureKind(), clang::sema::CapturedRegionScopeInfo::TheRecordDecl, clang::CapturedStmt::VCK_ByCopy, clang::CapturedStmt::VCK_ByRef, clang::CapturedStmt::VCK_This, and clang::CapturedStmt::VCK_VLAType.
Referenced by clang::Sema::ActOnCapturedRegionEnd().
◆ BuildNonArrayForRange()
static Sema::ForRangeStatus BuildNonArrayForRange ( Sema & SemaRef, Expr * BeginRange, Expr * EndRange, QualType RangeType, VarDecl * BeginVar, VarDecl * EndVar, SourceLocation ColonLoc, SourceLocation CoawaitLoc, OverloadCandidateSet * CandidateSet, ExprResult * BeginExpr, ExprResult * EndExpr, BeginEndFunction * BEF ) | static |
---|
Create the initialization, compare, and increment steps for the range-based for loop expression.
This function does not handle array-based for loops, which are created in Sema::BuildCXXForRangeStmt.
Returns
a ForRangeStatus indicating success or what kind of error occurred. BeginExpr and EndExpr are set and FRS_Success is returned on success; CandidateSet and BEF are set and some non-success value is returned on failure.
Definition at line 2513 of file SemaStmt.cpp.
References clang::Sema::ActOnCoawaitExpr(), clang::Sema::BuildForRangeBeginEndCall(), D, clang::SemaBase::Diag(), clang::LookupResult::empty(), FinishForRangeVarDecl(), clang::Found, clang::Sema::FRS_DiagnosticIssued, clang::Sema::FRS_NoViableFunction, clang::Sema::FRS_Success, clang::ActionResult< PtrTy, Compress >::get(), clang::IdentifierTable::get(), clang::Type::getAsCXXRecordDecl(), clang::Stmt::getBeginLoc(), clang::Sema::getCurScope(), clang::Preprocessor::getIdentifierTable(), clang::Decl::getLocation(), clang::Expr::getType(), clang::LookupResult::isAmbiguous(), clang::SourceLocation::isInvalid(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Sema::LookupMemberName, clang::Sema::LookupQualifiedName(), clang::OverloadCandidateSet::NoteCandidates(), clang::OCD_AllCandidates, clang::SemaBase::PDiag(), clang::Sema::PP, and clang::Result.
Referenced by clang::Sema::BuildCXXForRangeStmt().
◆ checkCaseValue()
◆ checkEnumTypesInSwitchStmt()
static void checkEnumTypesInSwitchStmt ( Sema & S, const Expr * Cond, const Expr * Case ) | static |
---|
◆ CheckJumpOutOfSEHFinally()
◆ CheckSimplerImplicitMovesMSVCWorkaround()
static bool CheckSimplerImplicitMovesMSVCWorkaround ( const Sema & S, const Expr * E ) | static |
---|
◆ CmpCaseVals()
◆ CmpEnumVals()
◆ DiagnoseForRangeConstVariableCopies()
static void DiagnoseForRangeConstVariableCopies ( Sema & SemaRef, const VarDecl * VD ) | static |
---|
Definition at line 3115 of file SemaStmt.cpp.
References clang::Sema::Context, clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), clang::DeclaratorDecl::getBeginLoc(), clang::VarDecl::getInit(), clang::Decl::getLocation(), clang::ASTContext::getLValueReferenceType(), clang::VarDecl::getSourceRange(), clang::ValueDecl::getType(), clang::ASTContext::getTypeSize(), hasTrivialABIAttr(), and clang::QualType::isTriviallyCopyConstructibleType().
Referenced by DiagnoseForRangeVariableCopies().
◆ DiagnoseForRangeReferenceVariableCopies()
static void DiagnoseForRangeReferenceVariableCopies ( Sema & SemaRef, const VarDecl * VD, QualType RangeInitType ) | static |
---|
Definition at line 3026 of file SemaStmt.cpp.
References clang::Call, clang::Sema::Context, clang::FixItHint::CreateRemoval(), clang::SemaBase::Diag(), E, clang::MemberExpr::getBase(), clang::DeclaratorDecl::getBeginLoc(), clang::VarDecl::getInit(), clang::Decl::getLocation(), clang::ASTContext::getLValueReferenceType(), clang::QualType::getNonReferenceType(), clang::FunctionDecl::getReturnType(), clang::VarDecl::getSourceRange(), clang::MaterializeTemporaryExpr::getSubExpr(), clang::ValueDecl::getType(), clang::Expr::getType(), clang::DeclaratorDecl::getTypeSpecEndLoc(), clang::Expr::IgnoreImpCasts(), clang::QualType::isNull(), clang::Type::isReferenceType(), clang::Type::isRValueReferenceType(), clang::QualType::removeLocalConst(), and clang::QualType::withConst().
Referenced by DiagnoseForRangeVariableCopies().
◆ DiagnoseForRangeVariableCopies()
static void DiagnoseForRangeVariableCopies ( Sema & SemaRef, const CXXForRangeStmt * ForStmt ) | static |
---|
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them.
- for (const foo &x : foos) where foos only returns a copy. Suggest using "const foo x" to show that a copy is made 2) for (const bar &x : foos) where bar is a temporary initialized by bar. Suggest either "const bar x" to keep the copying or "const foo& x" to prevent the copy. 3) for (const foo x : foos) where x is constructed from a reference foo. Suggest "const foo &x" to prevent the copy.
Definition at line 3160 of file SemaStmt.cpp.
References DiagnoseForRangeConstVariableCopies(), DiagnoseForRangeReferenceVariableCopies(), clang::Sema::Diags, clang::ForStmt::getBeginLoc(), clang::Expr::getExprLoc(), clang::VarDecl::getInit(), clang::ValueDecl::getType(), clang::Sema::inTemplateInstantiation(), clang::QualType::isConstQualified(), clang::DiagnosticsEngine::isIgnored(), clang::Type::isIncompleteType(), clang::SourceLocation::isMacroID(), and clang::Type::isReferenceType().
Referenced by clang::Sema::FinishCXXForRangeStmt().
◆ DiagnoseNoDiscard()
◆ DiagnoseUnusedComparison()
static bool DiagnoseUnusedComparison ( Sema & S, const Expr * E ) | static |
---|
◆ EqEnumVals()
◆ FinishForRangeVarDecl()
Finish building a variable declaration for a for-range statement.
Returns
true if an error occurs.
Definition at line 2328 of file SemaStmt.cpp.
References clang::DeclContext::addHiddenDecl(), clang::Sema::AddInitializerToDecl(), clang::AlreadyDiagnosed, clang::Sema::CorrectDelayedTyposInExpr(), clang::Sema::CurContext, clang::Sema::DeduceAutoType(), clang::SemaBase::Diag(), clang::Sema::FinalizeDeclaration(), clang::ActionResult< PtrTy, Compress >::get(), clang::Sema::getLangOpts(), clang::SemaObjC::inferObjCARCLifetime(), clang::Init, clang::QualType::isNull(), clang::ActionResult< PtrTy, Compress >::isUsable(), Loc, clang::Sema::ObjC(), clang::Result, clang::Decl::setInvalidDecl(), and clang::Success.
Referenced by clang::Sema::ActOnCXXForRangeStmt(), clang::Sema::BuildCXXForRangeStmt(), and BuildNonArrayForRange().
◆ GetTypeBeforeIntegralPromotion()
static QualType GetTypeBeforeIntegralPromotion ( const Expr *& E) | static |
---|
◆ hasDeducedReturnType()
◆ hasTrivialABIAttr()
static bool hasTrivialABIAttr ( QualType VariableType) | static |
---|
◆ ObjCEnumerationCollection()
static bool ObjCEnumerationCollection ( Expr * Collection) | static |
---|
◆ RebuildForRangeWithDereference()
Speculatively attempt to dereference an invalid range expression.
If the attempt fails, this function will return a valid, null StmtResult and emit no diagnostics.
Definition at line 2647 of file SemaStmt.cpp.
References clang::Sema::ActOnCXXForRangeStmt(), clang::Sema::BFRK_Check, clang::Sema::BFRK_Rebuild, clang::Sema::BuildUnaryOp(), clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::ActionResult< PtrTy, Compress >::isInvalid(), and Range.
Referenced by clang::Sema::BuildCXXForRangeStmt().
◆ ShouldDiagnoseSwitchCaseNotInEnum()
static bool ShouldDiagnoseSwitchCaseNotInEnum ( const Sema & S, const EnumDecl * ED, const Expr * CaseExpr, EnumValsTy::iterator & EI, EnumValsTy::iterator & EIEnd, const llvm::APSInt & Val ) | static |
---|