clang 20.0.0git
|
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/ASTLambda.h"
#include "clang/AST/CXXInheritance.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/IgnoreExpr.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/EnterExpressionEvaluationContext.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/Ownership.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/SemaCUDA.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaObjC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/STLForwardCompat.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
Go to the source code of this file.
Classes | |
struct | llvm::DenseMapInfo< CatchHandlerType > |
Namespaces | |
namespace | llvm |
Diagnostic wrappers for TextAPI types for error reporting. | |
Typedefs | |
typedef SmallVector< std::pair< llvm::APSInt, EnumConstantDecl * >, 64 > | EnumValsTy |
Functions | |
static bool | DiagnoseUnusedComparison (Sema &S, const Expr *E) |
Diagnose unused comparisons, both builtin and overloaded operators. | |
static bool | DiagnoseNoDiscard (Sema &S, 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) |
typedef SmallVector<std::pair<llvm::APSInt, EnumConstantDecl*>, 64> EnumValsTy |
Definition at line 1183 of file SemaStmt.cpp.
|
static |
Definition at line 1154 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt(), checkCaseValue(), and clang::Sema::DiagnoseAssignmentEnum().
|
static |
Definition at line 4436 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().
|
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 2423 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().
|
static |
Check the specified case value is in range for the given unpromoted switch type.
Definition at line 1161 of file SemaStmt.cpp.
References AdjustAPSInt(), clang::SemaBase::Diag(), clang::Sema::getLangOpts(), Loc, and toString().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
Definition at line 1219 of file SemaStmt.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Type::getAs(), clang::EnumType::getDecl(), clang::Expr::getExprLoc(), clang::NamedDecl::getIdentifier(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::TagDecl::getTypedefNameForAnonDecl(), and clang::ASTContext::hasSameUnqualifiedType().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
Definition at line 3173 of file SemaStmt.cpp.
References clang::Scope::Contains(), clang::Sema::CurrentSEHFinally, clang::SemaBase::Diag(), and Loc.
Referenced by clang::Sema::ActOnBreakStmt(), clang::Sema::ActOnContinueStmt(), clang::Sema::ActOnReturnStmt(), and clang::Sema::ActOnSEHLeaveStmt().
Definition at line 3776 of file SemaStmt.cpp.
References D, E, clang::Decl::getDeclContext(), clang::Sema::getLangOpts(), clang::Decl::getLocation(), clang::DeclContext::getParent(), clang::Expr::getReferencedDeclOfCallee(), clang::SourceManager::isInSystemHeader(), clang::DeclContext::isStdNamespace(), and clang::Sema::SourceMgr.
Referenced by clang::Sema::BuildReturnStmt().
|
static |
CmpCaseVals - Comparison predicate for sorting case values.
Definition at line 1019 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
CmpEnumVals - Comparison predicate for sorting enumeration values.
Definition at line 1032 of file SemaStmt.cpp.
Referenced by clang::Sema::ActOnFinishSwitchStmt(), and clang::Sema::DiagnoseAssignmentEnum().
Definition at line 3025 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().
|
static |
Definition at line 2936 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().
|
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 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 3070 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().
|
static |
Definition at line 206 of file SemaStmt.cpp.
References clang::SemaBase::Diag(), and Loc.
Referenced by clang::Sema::DiagnoseUnusedExprResult().
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 135 of file SemaStmt.cpp.
References clang::FixItHint::CreateReplacement(), clang::SemaBase::Diag(), E, clang::Stmt::getSourceRange(), clang::SourceManager::isMacroBodyExpansion(), Loc, and clang::Sema::SourceMgr.
Referenced by clang::Sema::DiagnoseUnusedExprResult().
|
static |
EqEnumVals - Comparison preficate for uniqing enumeration values.
Definition at line 1040 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 2238 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 - Returns the pre-promotion type of potentially integral-promoted expression expr
.
Definition at line 1048 of file SemaStmt.cpp.
References E, and clang::Expr::getType().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
Determine whether the declared return type of the specified function contains 'auto'.
Definition at line 3407 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().
Determines whether the VariableType's
declaration is a record with the clang::trivial_abi attribute.
Definition at line 3015 of file SemaStmt.cpp.
References clang::Type::getAsCXXRecordDecl().
Referenced by DiagnoseForRangeConstVariableCopies().
Definition at line 2330 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 2557 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().
|
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 1187 of file SemaStmt.cpp.
References clang::Sema::Context, clang::ASTContext::getTypeDeclType(), clang::Decl::hasAttr(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreParenImpCasts(), clang::EnumDecl::isClosed(), clang::QualType::isConstQualified(), and clang::Sema::IsValueInFlagEnum().
Referenced by clang::Sema::ActOnFinishSwitchStmt().
|
static |
Verify that the initialization sequence that was picked for the first overload resolution is permissible under C++98.
Reject (possibly converting) constructors not taking an rvalue reference, or user conversion operators which are not ref-qualified.
Definition at line 3357 of file SemaStmt.cpp.
References clang::FunctionDecl::getParamDecl(), clang::ValueDecl::getType(), clang::Type::isRValueReferenceType(), clang::RQ_None, and clang::Seq.
Referenced by clang::Sema::PerformMoveOrCopyInitialization().