clang
3.9.0
|
#include "clang/Sema/SemaInternal.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/TypeLoc.h"
#include "clang/AST/TypeOrdering.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
Go to the source code of this file.
Classes | |
struct | llvm::DenseMapInfo< CatchHandlerType > |
Namespaces | |
llvm | |
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterators. | |
Typedefs | |
typedef SmallVector< std::pair < llvm::APSInt, EnumConstantDecl * >, 64 > | EnumValsTy |
Enumerations | |
enum | BeginEndFunction |
Functions | |
static bool | DiagnoseUnusedComparison (Sema &S, const Expr *E) |
Diagnose unused comparisons, both builtin and overloaded operators. More... | |
static bool | CmpCaseVals (const std::pair< llvm::APSInt, CaseStmt * > &lhs, const std::pair< llvm::APSInt, CaseStmt * > &rhs) |
CmpCaseVals - Comparison predicate for sorting case values. More... | |
static bool | CmpEnumVals (const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs) |
CmpEnumVals - Comparison predicate for sorting enumeration values. More... | |
static bool | EqEnumVals (const std::pair< llvm::APSInt, EnumConstantDecl * > &lhs, const std::pair< llvm::APSInt, EnumConstantDecl * > &rhs) |
EqEnumVals - Comparison preficate for uniqing enumeration values. More... | |
static QualType | GetTypeBeforeIntegralPromotion (Expr *&expr) |
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expression expr . More... | |
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. More... | |
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. More... | |
static bool | FinishForRangeVarDecl (Sema &SemaRef, VarDecl *Decl, Expr *Init, SourceLocation Loc, int DiagID) |
Finish building a variable declaration for a for-range statement. More... | |
static bool | ObjCEnumerationCollection (Expr *Collection) |
static Sema::ForRangeStatus | BuildNonArrayForRange (Sema &SemaRef, Expr *BeginRange, Expr *EndRange, QualType RangeType, VarDecl *BeginVar, VarDecl *EndVar, SourceLocation ColonLoc, OverloadCandidateSet *CandidateSet, ExprResult *BeginExpr, ExprResult *EndExpr, BeginEndFunction *BEF) |
Create the initialization, compare, and increment steps for the range-based for loop expression. More... | |
static StmtResult | RebuildForRangeWithDereference (Sema &SemaRef, Scope *S, SourceLocation ForLoc, SourceLocation CoawaitLoc, Stmt *LoopVarDecl, SourceLocation ColonLoc, Expr *Range, SourceLocation RangeLoc, SourceLocation RParenLoc) |
Speculatively attempt to dereference an invalid range expression. More... | |
static void | DiagnoseForRangeReferenceVariableCopies (Sema &SemaRef, const VarDecl *VD, QualType RangeInitType) |
static void | DiagnoseForRangeConstVariableCopies (Sema &SemaRef, const VarDecl *VD) |
static void | DiagnoseForRangeVariableCopies (Sema &SemaRef, const CXXForRangeStmt *ForStmt) |
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them. More... | |
static void | CheckJumpOutOfSEHFinally (Sema &S, SourceLocation Loc, const Scope &DestScope) |
static bool | hasDeducedReturnType (FunctionDecl *FD) |
Determine whether the declared return type of the specified function contains 'auto'. More... | |
static void | buildCapturedStmtCaptureList (SmallVectorImpl< CapturedStmt::Capture > &Captures, SmallVectorImpl< Expr * > &CaptureInits, ArrayRef< CapturingScopeInfo::Capture > Candidates) |
typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl*>, 64> EnumValsTy |
Definition at line 704 of file SemaStmt.cpp.
enum BeginEndFunction |
Definition at line 1893 of file SemaStmt.cpp.
Definition at line 679 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt(), checkCaseValue(), and clang::Sema::DiagnoseAssignmentEnum().
|
static |
Definition at line 3853 of file SemaStmt.cpp.
References clang::CapturedStmt::VCK_ByCopy, clang::CapturedStmt::VCK_ByRef, clang::CapturedStmt::VCK_This, and clang::CapturedStmt::VCK_VLAType.
Referenced by clang::Sema::ActOnCapturedRegionEnd().
|
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.
Definition at line 2030 of file SemaStmt.cpp.
References clang::Sema::BuildForRangeBeginEndCall(), ColonLoc, clang::Sema::Diag(), clang::LookupResult::empty(), FinishForRangeVarDecl(), clang::Sema::FRS_DiagnosticIssued, clang::Sema::FRS_Success, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::IdentifierTable::get(), clang::Type::getAsCXXRecordDecl(), clang::Preprocessor::getIdentifierTable(), clang::Expr::getType(), clang::Sema::LookupMemberName, clang::Sema::LookupQualifiedName(), and clang::Sema::PP.
Referenced by clang::Sema::BuildCXXForRangeStmt().
|
static |
Check the specified case value is in range for the given unpromoted switch type.
Definition at line 686 of file SemaStmt.cpp.
References AdjustAPSInt(), and clang::Sema::Diag().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
Definition at line 2651 of file SemaStmt.cpp.
References clang::Scope::Contains(), clang::Sema::CurrentSEHFinally, and clang::Sema::Diag().
Referenced by clang::Sema::ActOnBreakStmt(), clang::Sema::ActOnContinueStmt(), clang::Sema::ActOnReturnStmt(), and clang::Sema::ActOnSEHLeaveStmt().
|
static |
CmpCaseVals - Comparison predicate for sorting case values.
Definition at line 569 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
CmpEnumVals - Comparison predicate for sorting enumeration values.
Definition at line 583 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt(), and clang::Sema::DiagnoseAssignmentEnum().
Definition at line 2521 of file SemaStmt.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::VarDecl::getInit(), clang::DeclaratorDecl::getLocStart(), clang::ASTContext::getLValueReferenceType(), clang::VarDecl::getSourceRange(), clang::Expr::getType(), clang::ValueDecl::getType(), and clang::QualType::isPODType().
Referenced by DiagnoseForRangeVariableCopies().
|
static |
Definition at line 2447 of file SemaStmt.cpp.
References clang::Sema::Context, clang::Sema::Diag(), E, clang::MemberExpr::getBase(), clang::CallExpr::getDirectCallee(), clang::VarDecl::getInit(), clang::DeclaratorDecl::getLocStart(), clang::ASTContext::getLValueReferenceType(), clang::QualType::getNonReferenceType(), clang::VarDecl::getSourceRange(), clang::MaterializeTemporaryExpr::GetTemporaryExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::Expr::IgnoreImpCasts(), clang::Type::isReferenceType(), clang::QualType::removeLocalConst(), and clang::QualType::withConst().
Referenced by DiagnoseForRangeVariableCopies().
|
static |
DiagnoseForRangeVariableCopies - Diagnose three cases and fixes for them.
1) 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 intialized 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 2562 of file SemaStmt.cpp.
References DiagnoseForRangeConstVariableCopies(), DiagnoseForRangeReferenceVariableCopies(), clang::Sema::Diags, clang::VarDecl::getInit(), clang::CXXForRangeStmt::getLocStart(), clang::CXXForRangeStmt::getLoopVariable(), clang::CXXForRangeStmt::getRangeInit(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::QualType::isConstQualified(), clang::DiagnosticsEngine::isIgnored(), clang::Type::isIncompleteType(), and clang::Type::isReferenceType().
Referenced by clang::Sema::FinishCXXForRangeStmt().
Diagnose unused comparisons, both builtin and overloaded operators.
For '==' and '!=', suggest fixits for '=' or '|='.
Adding a cast to void (or other expression wrappers) will prevent the warning from firing.
Definition at line 128 of file SemaStmt.cpp.
References clang::FixItHint::CreateReplacement(), clang::Sema::Diag(), clang::SourceManager::isMacroBodyExpansion(), and clang::Sema::SourceMgr.
Referenced by clang::Sema::DiagnoseUnusedExprResult().
|
static |
EqEnumVals - Comparison preficate for uniqing enumeration values.
Definition at line 591 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt(), and clang::Sema::DiagnoseAssignmentEnum().
|
static |
Finish building a variable declaration for a for-range statement.
Definition at line 1852 of file SemaStmt.cpp.
References clang::DeclContext::addHiddenDecl(), clang::Sema::AddInitializerToDecl(), clang::Sema::CorrectDelayedTyposInExpr(), clang::Sema::CurContext, clang::Sema::DAR_Failed, clang::Sema::DeduceAutoType(), clang::Sema::Diag(), clang::Sema::FinalizeDeclaration(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Sema::getLangOpts(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::DeclaratorDecl::getTypeSourceInfo(), clang::Sema::inferObjCARCLifetime(), clang::QualType::isNull(), clang::Type::isUndeducedType(), clang::ActionResult< PtrTy, CompressInvalid >::isUsable(), clang::Type::isVoidType(), and clang::ValueDecl::setType().
Referenced by clang::Sema::ActOnCXXForRangeStmt(), clang::Sema::BuildCXXForRangeStmt(), and BuildNonArrayForRange().
GetTypeBeforeIntegralPromotion - Returns the pre-promotion type of potentially integral-promoted expression expr
.
Definition at line 599 of file SemaStmt.cpp.
References clang::Expr::getType().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
Determine whether the declared return type of the specified function contains 'auto'.
Definition at line 2850 of file SemaStmt.cpp.
References clang::Type::castAs(), clang::FunctionType::getReturnType(), clang::TypeSourceInfo::getType(), clang::DeclaratorDecl::getTypeSourceInfo(), and clang::Type::isUndeducedType().
Referenced by clang::Sema::ActOnCapScopeReturnStmt().
Definition at line 1938 of file SemaStmt.cpp.
References clang::Type::getAs(), clang::Expr::getType(), and clang::Expr::isTypeDependent().
Referenced by clang::Sema::ActOnCXXForRangeStmt().
|
static |
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 2114 of file SemaStmt.cpp.
References clang::Sema::ActOnCXXForRangeStmt(), clang::Sema::BFRK_Check, clang::Sema::BFRK_Rebuild, clang::Sema::BuildUnaryOp(), clang::FixItHint::CreateInsertion(), clang::Sema::Diag(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::Expr::getType(), and clang::ActionResult< PtrTy, CompressInvalid >::isInvalid().
Referenced by clang::Sema::BuildCXXForRangeStmt().
|
static |
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.
Definition at line 708 of file SemaStmt.cpp.
References clang::Sema::Context, clang::ASTContext::getTypeDeclType(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreParenImpCasts(), clang::QualType::isConstQualified(), and clang::Sema::IsValueInFlagEnum().
Referenced by clang::Sema::ActOnFinishSwitchStmt().