clang
3.9.0
|
#include "clang/Sema/SemaInternal.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/CharUnits.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/Expr.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ExprOpenMP.h"
#include "clang/AST/StmtCXX.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Analysis/Analyses/FormatString.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/TargetBuiltins.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Lexer.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/Sema.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallBitVector.h"
#include "llvm/ADT/SmallString.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/Locale.h"
#include "llvm/Support/ConvertUTF.h"
#include "llvm/Support/raw_ostream.h"
#include <limits>
#include "clang/Basic/Builtins.def"
#include "clang/Basic/arm_neon.inc"
Go to the source code of this file.
Macros | |
#define | BUILTIN(ID, TYPE, ATTRS) |
#define | ATOMIC_BUILTIN(ID, TYPE, ATTRS) |
#define | GET_NEON_OVERLOAD_CHECK |
#define | GET_NEON_IMMEDIATE_CHECK |
#define | BUILTIN_ROW(x) |
Enumerations | |
enum | StringLiteralCheckType |
enum | AbsoluteValueKind { AVK_Integer, AVK_Floating, AVK_Complex } |
Functions | |
static bool | checkArgCount (Sema &S, CallExpr *call, unsigned desiredArgCount) |
Checks that a call expression's argument count is the desired number. More... | |
static bool | SemaBuiltinAnnotation (Sema &S, CallExpr *TheCall) |
Check that the first argument to __builtin_annotation is an integer and the second argument is a non-wide string literal. More... | |
static bool | SemaBuiltinAddressof (Sema &S, CallExpr *TheCall) |
Check that the argument to __builtin_addressof is a glvalue, and set the result type to the corresponding pointer type. More... | |
static bool | SemaBuiltinOverflow (Sema &S, CallExpr *TheCall) |
static void | SemaBuiltinMemChkCall (Sema &S, FunctionDecl *FDecl, CallExpr *TheCall, unsigned SizeIdx, unsigned DstSizeIdx) |
static bool | SemaBuiltinCallWithStaticChain (Sema &S, CallExpr *BuiltinCall) |
static bool | SemaBuiltinSEHScopeCheck (Sema &SemaRef, CallExpr *TheCall, Scope::ScopeFlags NeededScopeFlags, unsigned DiagID) |
static bool | isBlockPointer (Expr *Arg) |
static bool | checkOpenCLBlockArgs (Sema &S, Expr *BlockArg) |
OpenCL C v2.0, s6.13.17.2 - Checks that the block parameters are all local void*, which is a requirement of device side enqueue. More... | |
static bool | SemaOpenCLBuiltinKernelWorkGroupSize (Sema &S, CallExpr *TheCall) |
OpenCL C v2.0, s6.13.17.6 - Check the argument to the get_kernel_work_group_size and get_kernel_preferred_work_group_size_multiple builtin functions. More... | |
static bool | checkOpenCLEnqueueLocalSizeArgs (Sema &S, CallExpr *TheCall, unsigned Start, unsigned End) |
static bool | checkOpenCLEnqueueVariadicArgs (Sema &S, CallExpr *TheCall, Expr *BlockArg, unsigned NumNonVarArgs) |
OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all 'local void*' parameter of passed block. More... | |
static bool | SemaOpenCLBuiltinEnqueueKernel (Sema &S, CallExpr *TheCall) |
OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different overload formats specified in Table 6.13.17.1. More... | |
static OpenCLAccessAttr * | getOpenCLArgAccess (const Decl *D) |
Returns OpenCL access qual. More... | |
static bool | checkOpenCLPipeArg (Sema &S, CallExpr *Call) |
Returns true if pipe element type is different from the pointer. More... | |
static bool | checkOpenCLPipePacketType (Sema &S, CallExpr *Call, unsigned Idx) |
Returns true if pipe element type is different from the pointer. More... | |
static bool | SemaBuiltinRWPipe (Sema &S, CallExpr *Call) |
static bool | SemaBuiltinReserveRWPipe (Sema &S, CallExpr *Call) |
static bool | SemaBuiltinCommitRWPipe (Sema &S, CallExpr *Call) |
static bool | SemaBuiltinPipePackets (Sema &S, CallExpr *Call) |
static bool | SemaOpenCLBuiltinToAddr (Sema &S, unsigned BuiltinID, CallExpr *Call) |
static unsigned | RFT (unsigned t, bool shift=false, bool ForceQuad=false) |
static QualType | getNeonEltType (NeonTypeFlags Flags, ASTContext &Context, bool IsPolyUnsigned, bool IsInt64Long) |
getNeonEltType - Return the QualType corresponding to the elements of the vector type specified by the NeonTypeFlags. More... | |
static bool | SemaBuiltinCpuSupports (Sema &S, CallExpr *TheCall) |
SemaBuiltinCpuSupports - Handle __builtin_cpu_supports(char *). More... | |
static bool | CheckNonNullExpr (Sema &S, const Expr *Expr) |
Checks if a the given expression evaluates to null. More... | |
static void | CheckNonNullArgument (Sema &S, const Expr *ArgExpr, SourceLocation CallSiteLoc) |
static void | DiagnoseCStringFormatDirectiveInCFAPI (Sema &S, const NamedDecl *FDecl, Expr **Args, unsigned NumArgs) |
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting method. More... | |
static bool | isNonNullType (ASTContext &ctx, QualType type) |
Determine whether the given type has a non-null nullability annotation. More... | |
static void | CheckNonNullArguments (Sema &S, const NamedDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< const Expr * > Args, SourceLocation CallSiteLoc) |
static bool | isValidOrderingForOp (int64_t Ordering, AtomicExpr::AtomicOp Op) |
static bool | checkBuiltinArgument (Sema &S, CallExpr *E, unsigned ArgIndex) |
checkBuiltinArgument - Given a call to a builtin function, perform normal type-checking on the given argument, updating the call in place. More... | |
static void | CheckFormatString (Sema &S, const StringLiteral *FExpr, const Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, bool inFunctionCall, Sema::VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg) |
static StringLiteralCheckType | checkFormatStringExpr (Sema &S, const Expr *E, ArrayRef< const Expr * > Args, bool HasVAListArg, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, Sema::VariadicCallType CallType, bool InFunctionCall, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg) |
template<typename MemberKind > | |
static llvm::SmallPtrSet < MemberKind *, 1 > | CXXRecordMembersNamed (StringRef Name, Sema &S, QualType Ty) |
static bool | requiresParensToAddCast (const Expr *E) |
static std::pair< QualType, StringRef > | shouldNotPrintDirectly (const ASTContext &Context, QualType IntendedTy, const Expr *E) |
static unsigned | getLargerAbsoluteValueFunction (unsigned AbsFunction) |
static QualType | getAbsoluteValueArgumentType (ASTContext &Context, unsigned AbsType) |
static unsigned | getBestAbsFunction (ASTContext &Context, QualType ArgType, unsigned AbsFunctionKind) |
static AbsoluteValueKind | getAbsoluteValueKind (QualType T) |
static unsigned | changeAbsFunction (unsigned AbsKind, AbsoluteValueKind ValueKind) |
static unsigned | getAbsoluteValueFunctionKind (const FunctionDecl *FDecl) |
static void | emitReplacement (Sema &S, SourceLocation Loc, SourceRange Range, unsigned AbsKind, QualType ArgType) |
static bool | IsFunctionStdAbs (const FunctionDecl *FDecl) |
static bool | CheckMemorySizeofForComparison (Sema &S, const Expr *E, IdentifierInfo *FnName, SourceLocation FnLoc, SourceLocation RParenLoc) |
Takes the expression passed to the size_t parameter of functions such as memcmp, strncat, etc and warns if it's a comparison. More... | |
static const CXXRecordDecl * | getContainedDynamicClass (QualType T, bool &IsContained) |
Determine whether the given type is or contains a dynamic class type (e.g., whether it has a vtable). More... | |
static const Expr * | getSizeOfExprArg (const Expr *E) |
If E is a sizeof expression, returns its argument expression, otherwise returns NULL. More... | |
static QualType | getSizeOfArgType (const Expr *E) |
If E is a sizeof expression, returns its argument type. More... | |
static const Expr * | ignoreLiteralAdditions (const Expr *Ex, ASTContext &Ctx) |
static bool | isConstantSizeArrayWithMoreThanOneElement (QualType Ty, ASTContext &Context) |
static bool | referToTheSameDecl (const Expr *E1, const Expr *E2) |
Check if two expressions refer to the same declaration. More... | |
static const Expr * | getStrlenExprArg (const Expr *E) |
static const Expr * | EvalVal (const Expr *E, SmallVectorImpl< const DeclRefExpr * > &refVars, const Decl *ParentDecl) |
EvalVal - This function is complements EvalAddr in the mutual recursion. More... | |
static const Expr * | EvalAddr (const Expr *E, SmallVectorImpl< const DeclRefExpr * > &refVars, const Decl *ParentDecl) |
EvalAddr - EvalAddr and EvalVal are mutually recursive functions that check if the expression in a return statement evaluates to an address to a location on the stack, a local block, an address of a label, or a reference to local temporary. More... | |
static void | CheckReturnStackAddr (Sema &S, Expr *RetValExp, QualType lhsType, SourceLocation ReturnLoc) |
CheckReturnStackAddr - Check if a return statement returns the address of a stack variable. More... | |
static bool | CheckForReference (Sema &SemaRef, const Expr *E, const PartialDiagnostic &PD) |
static bool | IsInAnyMacroBody (const SourceManager &SM, SourceLocation Loc) |
static void | diagnoseArrayStarInParamType (Sema &S, QualType PType, SourceLocation Loc) |
static bool | IsTailPaddedMemberArray (Sema &S, const llvm::APInt &Size, const NamedDecl *ND) |
Check whether this array fits the idiom of a size-one tail padded array member of a struct. More... | |
static bool | considerVariable (VarDecl *var, Expr *ref, RetainCycleOwner &owner) |
Consider whether capturing the given variable can possibly lead to a retain cycle. More... | |
static bool | findRetainCycleOwner (Sema &S, Expr *e, RetainCycleOwner &owner) |
static Expr * | findCapturingExpr (Sema &S, Expr *e, RetainCycleOwner &owner) |
Check whether the given argument is a block which captures a variable. More... | |
static void | diagnoseRetainCycle (Sema &S, Expr *capturer, RetainCycleOwner &owner) |
static bool | isSetterLikeSelector (Selector sel) |
Check for a keyword selector that starts with the word 'add' or 'set'. More... | |
static Optional< int > | GetNSMutableArrayArgumentIndex (Sema &S, ObjCMessageExpr *Message) |
static Optional< int > | GetNSMutableDictionaryArgumentIndex (Sema &S, ObjCMessageExpr *Message) |
static Optional< int > | GetNSSetArgumentIndex (Sema &S, ObjCMessageExpr *Message) |
static bool | checkUnsafeAssignLiteral (Sema &S, SourceLocation Loc, Expr *RHS, bool isProperty) |
static bool | checkUnsafeAssignObject (Sema &S, SourceLocation Loc, Qualifiers::ObjCLifetime LT, Expr *RHS, bool isProperty) |
#define BUILTIN_ROW | ( | x | ) |
#define GET_NEON_IMMEDIATE_CHECK |
#define GET_NEON_OVERLOAD_CHECK |
enum AbsoluteValueKind |
Enumerator | |
---|---|
AVK_Integer | |
AVK_Floating | |
AVK_Complex |
Definition at line 5733 of file SemaChecking.cpp.
Definition at line 3786 of file SemaChecking.cpp.
|
static |
Definition at line 5752 of file SemaChecking.cpp.
References AVK_Complex, AVK_Floating, and AVK_Integer.
Checks that a call expression's argument count is the desired number.
This is useful when doing custom type-checking. Returns true on error.
Definition at line 56 of file SemaChecking.cpp.
References clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getLocEnd(), and clang::CallExpr::getNumArgs().
Referenced by SemaBuiltinAddressof(), SemaBuiltinAnnotation(), SemaBuiltinCallWithStaticChain(), SemaBuiltinCommitRWPipe(), SemaBuiltinOverflow(), SemaBuiltinPipePackets(), SemaBuiltinReserveRWPipe(), and SemaOpenCLBuiltinKernelWorkGroupSize().
checkBuiltinArgument - Given a call to a builtin function, perform normal type-checking on the given argument, updating the call in place.
This is useful when a builtin function requires custom type-checking for some of its arguments but not necessarily all of them.
Returns true on error.
Definition at line 2628 of file SemaChecking.cpp.
References clang::Sema::Context, clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::FunctionDecl::getParamDecl(), clang::InitializedEntity::InitializeParameter(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Sema::PerformCopyInitialization(), and clang::CallExpr::setArg().
|
static |
Definition at line 5546 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::FST_FreeBSDKPrintf, clang::Sema::FST_NSString, clang::Sema::FST_OSTrace, clang::Sema::FST_Printf, clang::Sema::FST_Scanf, clang::ASTContext::getAsConstantArrayType(), clang::Sema::getLangOpts(), clang::StringLiteral::getLocStart(), clang::ConstantArrayType::getSize(), clang::StringLiteral::getString(), clang::ASTContext::getTargetInfo(), clang::Expr::getType(), clang::StringLiteral::isAscii(), clang::StringLiteral::isUTF8(), max(), min(), clang::analyze_format_string::ParsePrintfString(), clang::analyze_format_string::ParseScanfString(), and clang::Sema::PDiag().
Referenced by checkFormatStringExpr().
|
static |
Definition at line 3809 of file SemaChecking.cpp.
References CheckFormatString(), clang::Sema::Context, E, clang::Expr::EvaluateAsBooleanCondition(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::Sema::getASTContext(), clang::CallExpr::getCalleeDecl(), clang::AbstractConditionalOperator::getCond(), clang::DeclRefExpr::getDecl(), clang::AbstractConditionalOperator::getFalseExpr(), clang::Sema::GetFormatStringType(), clang::StringLiteral::getString(), clang::AbstractConditionalOperator::getTrueExpr(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::QualType::isConstant(), clang::Expr::isNullPointerConstant(), clang::Type::isObjCObjectPointerType(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), and clang::Expr::NPC_ValueDependentIsNotNull.
|
static |
Definition at line 8612 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getCallReturnType(), clang::DeclRefExpr::getDecl(), clang::CallExpr::getDirectCallee(), clang::Expr::getExprLoc(), clang::ValueDecl::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::Type::isReferenceType().
Referenced by clang::Sema::DiagnoseAlwaysNonNullPointer().
|
static |
Takes the expression passed to the size_t parameter of functions such as memcmp, strncat, etc and warns if it's a comparison.
This is to catch typos like if (memcmp(&a, &b, sizeof(a) > 0))
.
Definition at line 6040 of file SemaChecking.cpp.
References clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), clang::Sema::Diag(), E, clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), clang::BinaryOperator::getLHS(), clang::Sema::getLocForEndOfToken(), clang::BinaryOperator::getOperatorLoc(), clang::BinaryOperator::isComparisonOp(), clang::BinaryOperator::isEqualityOp(), and clang::BinaryOperator::isLogicalOp().
|
static |
Definition at line 1922 of file SemaChecking.cpp.
References CheckNonNullExpr(), clang::Sema::DiagRuntimeBehavior(), and clang::Sema::PDiag().
Referenced by CheckNonNullArguments().
|
static |
Definition at line 1989 of file SemaChecking.cpp.
References CheckNonNullArgument(), clang::Sema::Context, E, clang::Type::getAs(), clang::FunctionProtoType::getParamTypes(), clang::Type::getPointeeType(), clang::PointerType::getPointeeType(), clang::Expr::getType(), clang::ValueDecl::getType(), I, isNonNullType(), clang::Sema::isValidPointerAttrType(), clang::NonNull, and clang::ast_matchers::type.
Checks if a the given expression evaluates to null.
Returns true if the value evaluates to null.
Definition at line 1897 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Expr::EvaluateAsBooleanCondition(), clang::Type::getAsUnionType(), clang::Type::getNullability(), clang::Expr::getType(), clang::Expr::IgnoreImplicit(), clang::Expr::isValueDependent(), and clang::NonNull.
Referenced by CheckNonNullArgument().
OpenCL C v2.0, s6.13.17.2 - Checks that the block parameters are all local void*, which is a requirement of device side enqueue.
Definition at line 270 of file SemaChecking.cpp.
References clang::Sema::Diag(), E, clang::Type::getAs(), clang::QualType::getCanonicalType(), clang::DeclaratorDecl::getLocStart(), clang::BlockDecl::getParamDecl(), clang::BlockPointerType::getPointeeType(), clang::Expr::getType(), I, and clang::LangAS::opencl_local.
Referenced by SemaOpenCLBuiltinEnqueueKernel(), and SemaOpenCLBuiltinKernelWorkGroupSize().
|
static |
Definition at line 8589 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), End, clang::CallExpr::getArg(), clang::CharUnits::getQuantity(), clang::Expr::getType(), clang::ASTContext::getTypeSizeInChars(), I, clang::Type::isIntegerType(), and clang::ASTContext::UnsignedIntTy.
Referenced by checkOpenCLEnqueueVariadicArgs().
|
static |
OpenCL v2.0, s6.13.17.1 - Check that sizes are provided for all 'local void*' parameter of passed block.
Definition at line 324 of file SemaChecking.cpp.
References checkOpenCLEnqueueLocalSizeArgs(), clang::Sema::Diag(), clang::Type::getAs(), clang::QualType::getCanonicalType(), clang::CallExpr::getLocStart(), clang::CallExpr::getNumArgs(), clang::BlockPointerType::getPointeeType(), and clang::Expr::getType().
Referenced by SemaOpenCLBuiltinEnqueueKernel().
Returns true if pipe element type is different from the pointer.
Definition at line 490 of file SemaChecking.cpp.
References clang::Sema::Diag(), clang::CallExpr::getArg(), clang::FunctionDecl::getBuiltinID(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), getOpenCLArgAccess(), clang::Expr::getType(), and clang::Type::isPipeType().
Referenced by SemaBuiltinCommitRWPipe(), SemaBuiltinReserveRWPipe(), and SemaBuiltinRWPipe().
Returns true if pipe element type is different from the pointer.
Definition at line 540 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Type::getCanonicalTypeInternal(), clang::CallExpr::getDirectCallee(), clang::PipeType::getElementType(), clang::CallExpr::getLocStart(), clang::PointerType::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), and clang::ASTContext::hasSameType().
Referenced by SemaBuiltinRWPipe().
|
static |
CheckReturnStackAddr - Check if a return statement returns the address of a stack variable.
Definition at line 6508 of file SemaChecking.cpp.
References clang::Sema::Diag(), EvalAddr(), EvalVal(), clang::DeclRefExpr::getDecl(), clang::NamedDecl::getDeclName(), clang::Sema::getLangOpts(), clang::tooling::fixit::internal::getSourceRange(), clang::Type::isBlockPointerType(), clang::Type::isPointerType(), and clang::Type::isReferenceType().
|
static |
Definition at line 10212 of file SemaChecking.cpp.
References clang::Sema::CheckLiteralKind(), clang::Sema::Diag(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::LK_None, and clang::Sema::LK_String.
Referenced by checkUnsafeAssignObject().
|
static |
Definition at line 10233 of file SemaChecking.cpp.
References clang::cast(), checkUnsafeAssignLiteral(), clang::Sema::Diag(), clang::Qualifiers::OCL_ExplicitNone, and clang::Qualifiers::OCL_Weak.
Referenced by clang::Sema::checkUnsafeAssigns(), and clang::Sema::checkUnsafeExprAssigns().
Consider whether capturing the given variable can possibly lead to a retain cycle.
Definition at line 9784 of file SemaChecking.cpp.
References clang::QualType::getObjCLifetime(), clang::ValueDecl::getType(), and clang::Qualifiers::OCL_Strong.
Referenced by clang::Sema::checkRetainCycles(), and findRetainCycleOwner().
|
static |
Definition at line 4802 of file SemaChecking.cpp.
References clang::Sema::Context, clang::ast_matchers::decl, E, clang::IdentifierTable::get(), clang::Type::getAs(), clang::RecordType::getDecl(), clang::CXXRecordDecl::getDefinition(), I, clang::ASTContext::Idents, clang::Sema::LookupMemberName, clang::Sema::LookupQualifiedName(), and clang::LookupResult::suppressDiagnostics().
|
static |
Definition at line 9406 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::ASTContext::getAsArrayType(), clang::ArrayType::getElementType(), clang::ArrayType::getSizeModifier(), clang::Type::isVariablyModifiedType(), and clang::ArrayType::Star.
Referenced by clang::Sema::CheckParmsForFunctionDef().
|
static |
Diagnose use of s directive in an NSString which is being passed as formatting string to formatting method.
Definition at line 1942 of file SemaChecking.cpp.
References clang::Sema::Diag(), clang::Sema::FormatStringHasSArg(), clang::NamedDecl::getDeclName(), clang::Expr::getExprLoc(), clang::Sema::GetFormatNSStringIdx(), clang::NamedDecl::getObjCFStringFormattingFamily(), clang::StringLiteral::getString(), I, clang::Expr::IgnoreParenImpCasts(), and clang::SFF_CFString.
Definition at line 9965 of file SemaChecking.cpp.
References clang::Sema::Diag(), and clang::Expr::getExprLoc().
Referenced by clang::Sema::checkRetainCycles().
|
static |
Definition at line 5849 of file SemaChecking.cpp.
References clang::ASTContext::BuiltinInfo, clang::Sema::Context, clang::FixItHint::CreateReplacement(), clang::Sema::Diag(), clang::IdentifierTable::get(), getAbsoluteValueKind(), clang::FunctionDecl::getBuiltinID(), clang::Sema::getCurScope(), clang::Builtin::Context::getHeaderName(), clang::Sema::getLangOpts(), clang::Builtin::Context::getName(), clang::FunctionDecl::getNumParams(), clang::FunctionDecl::getParamDecl(), clang::Sema::getStdNamespace(), clang::ValueDecl::getType(), clang::ASTContext::getTypeSize(), I, clang::ASTContext::Idents, clang::Type::isAnyComplexType(), clang::Type::isIntegralOrEnumerationType(), clang::Type::isRealFloatingType(), clang::Sema::LookupAnyName, clang::Sema::LookupName(), and clang::Sema::LookupQualifiedName().
|
static |
EvalAddr - EvalAddr and EvalVal are mutually recursive functions that check if the expression in a return statement evaluates to an address to a location on the stack, a local block, an address of a label, or a reference to local temporary.
The recursion is used to traverse the AST of the return expression, with recursion backtracking when we encounter a subexpression that (1) clearly does not lead to one of the above problematic expressions (2) is something we cannot determine leads to a problematic expression based on such local checking.
Both EvalAddr and EvalVal follow through reference variables to evaluate the expression that they point to. Such variables are added to the 'refVars' vector so that we know what the reference variable "trail" was.
EvalAddr processes expressions that are pointers that are used as references (and not L-values). EvalVal handles all other values. At the base case of the recursion is a check for the above problematic expressions.
This implementation handles:
Definition at line 6606 of file SemaChecking.cpp.
References E, EvalVal(), clang::DeclRefExpr::getDecl(), clang::BinaryOperator::getLHS(), clang::ConditionalOperator::getLHS(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::ConditionalOperator::getRHS(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::Expr::IgnoreParens(), clang::Type::isAnyPointerType(), clang::Type::isBlockPointerType(), clang::Type::isObjCQualifiedIdType(), clang::Type::isPointerType(), clang::Expr::isTypeDependent(), clang::Type::isVoidType(), and clang::DeclRefExpr::refersToEnclosingVariableOrCapture().
Referenced by CheckReturnStackAddr(), and EvalVal().
|
static |
EvalVal - This function is complements EvalAddr in the mutual recursion.
See the comments for EvalAddr for more details.
Definition at line 6761 of file SemaChecking.cpp.
References E, EvalAddr(), clang::MemberExpr::getBase(), clang::DeclRefExpr::getDecl(), clang::ConditionalOperator::getLHS(), clang::MemberExpr::getMemberDecl(), clang::UnaryOperator::getOpcode(), clang::ConditionalOperator::getRHS(), clang::UnaryOperator::getSubExpr(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::Expr::getValueKind(), clang::Expr::IgnoreParens(), clang::MemberExpr::isArrow(), clang::Type::isReferenceType(), clang::Expr::isRValue(), clang::Expr::isTypeDependent(), clang::Type::isVoidType(), clang::DeclRefExpr::refersToEnclosingVariableOrCapture(), and clang::VK_LValue.
Referenced by CheckReturnStackAddr(), and EvalAddr().
Check whether the given argument is a block which captures a variable.
Definition at line 9930 of file SemaChecking.cpp.
References clang::BlockDecl::capturesVariable(), clang::Sema::Context, clang::CallExpr::getArg(), clang::BlockExpr::getBlockDecl(), clang::BlockDecl::getBody(), clang::CallExpr::getCalleeDecl(), clang::NamedDecl::getIdentifier(), clang::Selector::getNameForSlot(), clang::CallExpr::getNumArgs(), clang::Expr::IgnoreParenCasts(), clang::IdentifierInfo::isStr(), and clang::Selector::isUnarySelector().
Referenced by clang::Sema::checkRetainCycles().
Definition at line 9797 of file SemaChecking.cpp.
References clang::cast(), considerVariable(), clang::ObjCPropertyRefExpr::getBase(), clang::Sema::getCurMethodDecl(), clang::ObjCPropertyRefExpr::getExplicitProperty(), clang::ObjCPropertyRefExpr::getLocation(), clang::QualType::getObjCLifetime(), clang::ObjCMethodDecl::getSelfDecl(), clang::ValueDecl::getType(), clang::Expr::IgnoreParens(), clang::ObjCPropertyRefExpr::isImplicitProperty(), clang::ObjCPropertyRefExpr::isSuperReceiver(), and clang::Qualifiers::OCL_Strong.
Referenced by clang::Sema::checkRetainCycles().
|
static |
Definition at line 5692 of file SemaChecking.cpp.
References clang::ASTContext::GE_None, clang::Type::getAs(), clang::ASTContext::GetBuiltinType(), clang::FunctionProtoType::getNumParams(), and clang::FunctionProtoType::getParamType().
Referenced by getBestAbsFunction().
|
static |
Definition at line 5816 of file SemaChecking.cpp.
References clang::FunctionDecl::getBuiltinID(), and clang::NamedDecl::getIdentifier().
|
static |
Definition at line 5739 of file SemaChecking.cpp.
References AVK_Complex, AVK_Floating, AVK_Integer, clang::Type::isAnyComplexType(), clang::Type::isIntegralOrEnumerationType(), and clang::Type::isRealFloatingType().
Referenced by emitReplacement().
|
static |
Definition at line 5714 of file SemaChecking.cpp.
References getAbsoluteValueArgumentType(), getLargerAbsoluteValueFunction(), clang::ASTContext::getTypeSize(), and clang::ASTContext::hasSameType().
|
static |
Determine whether the given type is or contains a dynamic class type (e.g., whether it has a vtable).
Definition at line 6069 of file SemaChecking.cpp.
References clang::RecordDecl::fields(), clang::Type::getAsCXXRecordDecl(), clang::Type::getBaseElementTypeUnsafe(), clang::CXXRecordDecl::getDefinition(), and clang::CXXRecordDecl::isDynamicClass().
Definition at line 5642 of file SemaChecking.cpp.
Referenced by getBestAbsFunction().
|
static |
getNeonEltType - Return the QualType corresponding to the elements of the vector type specified by the NeonTypeFlags.
This is used to check the pointer arguments for Neon load/store intrinsics.
Definition at line 1149 of file SemaChecking.cpp.
References clang::ASTContext::DoubleTy, clang::NeonTypeFlags::Float16, clang::NeonTypeFlags::Float32, clang::NeonTypeFlags::Float64, clang::ASTContext::FloatTy, clang::NeonTypeFlags::getEltType(), clang::ASTContext::HalfTy, clang::NeonTypeFlags::Int16, clang::NeonTypeFlags::Int32, clang::NeonTypeFlags::Int64, clang::NeonTypeFlags::Int8, clang::ASTContext::IntTy, clang::NeonTypeFlags::isUnsigned(), clang::ASTContext::LongLongTy, clang::ASTContext::LongTy, clang::NeonTypeFlags::Poly128, clang::NeonTypeFlags::Poly16, clang::NeonTypeFlags::Poly64, clang::NeonTypeFlags::Poly8, clang::ASTContext::ShortTy, clang::ASTContext::SignedCharTy, clang::ASTContext::UnsignedCharTy, clang::ASTContext::UnsignedIntTy, clang::ASTContext::UnsignedLongLongTy, clang::ASTContext::UnsignedLongTy, and clang::ASTContext::UnsignedShortTy.
|
static |
Definition at line 9998 of file SemaChecking.cpp.
References clang::NSAPI::ClassId_NSMutableArray, clang::ObjCMessageExpr::getReceiverInterface(), clang::ObjCMessageExpr::getSelector(), clang::None, clang::Sema::NSAPIObj, clang::NSAPI::NSMutableArr_addObject, clang::NSAPI::NSMutableArr_insertObjectAtIndex, clang::NSAPI::NSMutableArr_replaceObjectAtIndex, and clang::NSAPI::NSMutableArr_setObjectAtIndexedSubscript.
|
static |
Definition at line 10033 of file SemaChecking.cpp.
References clang::NSAPI::ClassId_NSMutableDictionary, clang::ObjCMessageExpr::getReceiverInterface(), clang::ObjCMessageExpr::getSelector(), clang::None, clang::Sema::NSAPIObj, clang::NSAPI::NSMutableDict_setObjectForKey, clang::NSAPI::NSMutableDict_setObjectForKeyedSubscript, and clang::NSAPI::NSMutableDict_setValueForKey.
|
static |
Definition at line 10065 of file SemaChecking.cpp.
References clang::NSAPI::ClassId_NSMutableOrderedSet, clang::NSAPI::ClassId_NSMutableSet, clang::ObjCMessageExpr::getReceiverInterface(), clang::ObjCMessageExpr::getSelector(), clang::None, clang::Sema::NSAPIObj, clang::NSAPI::NSMutableSet_addObject, clang::NSAPI::NSOrderedSet_insertObjectAtIndex, clang::NSAPI::NSOrderedSet_replaceObjectAtIndexWithObject, clang::NSAPI::NSOrderedSet_setObjectAtIndex, and clang::NSAPI::NSOrderedSet_setObjectAtIndexedSubscript.
|
static |
Returns OpenCL access qual.
Definition at line 485 of file SemaChecking.cpp.
Referenced by checkOpenCLPipeArg().
If E is a sizeof expression, returns its argument type.
Definition at line 6110 of file SemaChecking.cpp.
References clang::UETT_SizeOf.
If E is a sizeof expression, returns its argument expression, otherwise returns NULL.
Definition at line 6100 of file SemaChecking.cpp.
References clang::Expr::IgnoreParenImpCasts(), and clang::UETT_SizeOf.
Definition at line 6401 of file SemaChecking.cpp.
References clang::FunctionDecl::getMemoryFunctionKind().
|
static |
Definition at line 6289 of file SemaChecking.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getRHS(), clang::Expr::IgnoreParenCasts(), and clang::BinaryOperator::isAdditiveOp().
Definition at line 264 of file SemaChecking.cpp.
References clang::Expr::getType(), and clang::Type::isBlockPointerType().
Referenced by clang::CodeGen::CodeGenFunction::GenerateCopyHelperFunction(), inferARCWriteback(), SemaOpenCLBuiltinEnqueueKernel(), and SemaOpenCLBuiltinKernelWorkGroupSize().
|
static |
Definition at line 6311 of file SemaChecking.cpp.
References clang::ASTContext::getAsConstantArrayType(), and clang::Type::isVariableArrayType().
|
static |
Definition at line 5931 of file SemaChecking.cpp.
References clang::NamedDecl::getIdentifier(), clang::DeclContext::isInlineNamespace(), and clang::IdentifierInfo::isStr().
|
static |
Definition at line 8645 of file SemaChecking.cpp.
References clang::SourceManager::getImmediateMacroCallerLoc(), clang::SourceLocation::isInvalid(), clang::SourceManager::isMacroBodyExpansion(), and clang::SourceLocation::isMacroID().
Referenced by clang::Sema::DiagnoseAlwaysNonNullPointer().
|
static |
Determine whether the given type has a non-null nullability annotation.
Definition at line 1982 of file SemaChecking.cpp.
References clang::Type::getNullability(), and clang::NonNull.
Referenced by CheckNonNullArguments().
Check for a keyword selector that starts with the word 'add' or 'set'.
Definition at line 9978 of file SemaChecking.cpp.
References clang::Selector::getNameForSlot(), clang::Selector::getNumArgs(), clang::isLowercase(), and clang::Selector::isUnarySelector().
Referenced by clang::Sema::checkRetainCycles().
|
static |
Check whether this array fits the idiom of a size-one tail padded array member of a struct.
We avoid emitting out-of-bounds access warnings for such arrays as they are commonly used to emulate flexible arrays in C89 code.
Definition at line 9556 of file SemaChecking.cpp.
References clang::TypeLoc::getAs(), clang::Expr::getExprLoc(), clang::TypeSourceInfo::getTypeLoc(), clang::DeclaratorDecl::getTypeSourceInfo(), clang::TypedefNameDecl::getTypeSourceInfo(), clang::SourceLocation::isMacroID(), and clang::TagDecl::isUnion().
|
static |
Definition at line 2250 of file SemaChecking.cpp.
Check if two expressions refer to the same declaration.
Definition at line 6394 of file SemaChecking.cpp.
Definition at line 5022 of file SemaChecking.cpp.
References clang::Expr::IgnoreImpCasts().
Definition at line 1116 of file SemaChecking.cpp.
References clang::NeonTypeFlags::Float16, clang::NeonTypeFlags::Float32, clang::NeonTypeFlags::Float64, clang::NeonTypeFlags::getEltType(), clang::NeonTypeFlags::Int16, clang::NeonTypeFlags::Int32, clang::NeonTypeFlags::Int64, clang::NeonTypeFlags::Int8, clang::NeonTypeFlags::isQuad(), clang::NeonTypeFlags::Poly128, clang::NeonTypeFlags::Poly16, clang::NeonTypeFlags::Poly64, and clang::NeonTypeFlags::Poly8.
Check that the argument to __builtin_addressof is a glvalue, and set the result type to the corresponding pointer type.
Definition at line 104 of file SemaChecking.cpp.
References clang::Sema::CheckAddressOfOperand(), checkArgCount(), clang::CallExpr::getArg(), clang::CallExpr::getLocStart(), clang::CallExpr::setArg(), and clang::Expr::setType().
Check that the first argument to __builtin_annotation is an integer and the second argument is a non-wide string literal.
Definition at line 76 of file SemaChecking.cpp.
References checkArgCount(), clang::Sema::Diag(), clang::CallExpr::getArg(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::StringLiteral::isAscii(), clang::Type::isIntegerType(), and clang::Expr::setType().
Definition at line 179 of file SemaChecking.cpp.
References checkArgCount(), clang::Sema::Context, clang::Sema::Diag(), clang::ActionResult< PtrTy, CompressInvalid >::get(), clang::CallExpr::getArg(), clang::CallExpr::getCallee(), clang::ASTContext::getFunctionType(), clang::CallExpr::getLocStart(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::Expr::IgnoreImpCasts(), clang::Sema::ImpCastExprToType(), clang::ActionResult< PtrTy, CompressInvalid >::isInvalid(), clang::Type::isPointerType(), clang::CallExpr::setArg(), clang::CallExpr::setCallee(), clang::Expr::setObjectKind(), clang::Expr::setType(), clang::Expr::setValueKind(), and clang::Sema::UsualUnaryConversions().
Definition at line 642 of file SemaChecking.cpp.
References checkArgCount(), checkOpenCLPipeArg(), clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), clang::Expr::getType(), clang::Type::isReserveIDT(), and clang::ASTContext::OCLReserveIDTy.
SemaBuiltinCpuSupports - Handle __builtin_cpu_supports(char *).
This checks that the target supports __builtin_cpu_supports and that the string argument is constant and valid.
Definition at line 1575 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getLocStart(), clang::ASTContext::getTargetInfo(), clang::Expr::IgnoreParenImpCasts(), and clang::TargetInfo::validateCpuSupports().
|
static |
Definition at line 151 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::Expr::EvaluateAsInt(), clang::CallExpr::getArg(), clang::NamedDecl::getIdentifier(), clang::CallExpr::getLocStart(), and clang::CallExpr::getNumArgs().
Definition at line 118 of file SemaChecking.cpp.
References checkArgCount(), clang::Sema::Diag(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Expr::getType(), I, and clang::Type::isIntegerType().
Definition at line 665 of file SemaChecking.cpp.
References checkArgCount(), clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), clang::Expr::getType(), and clang::Type::isPipeType().
Definition at line 618 of file SemaChecking.cpp.
References checkArgCount(), checkOpenCLPipeArg(), clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), clang::Expr::getType(), clang::Type::isIntegerType(), clang::Type::isUnsignedIntegerType(), and clang::ASTContext::UnsignedIntTy.
Definition at line 563 of file SemaChecking.cpp.
References checkOpenCLPipeArg(), checkOpenCLPipePacketType(), clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), clang::CallExpr::getNumArgs(), clang::Expr::getType(), clang::Type::isIntegerType(), clang::Type::isReserveIDT(), clang::Type::isUnsignedIntegerType(), clang::ASTContext::OCLReserveIDTy, and clang::ASTContext::UnsignedIntTy.
|
static |
Definition at line 242 of file SemaChecking.cpp.
References clang::Sema::ActiveTemplateInstantiations, clang::Sema::Diag(), clang::CallExpr::getCallee(), clang::Sema::getCurScope(), clang::Expr::getExprLoc(), clang::Scope::getFlags(), clang::Scope::getParent(), clang::Expr::IgnoreParenCasts(), clang::Scope::isSEHExceptScope(), and S.
OpenCL C v2.0, s6.13.17 - Enqueue kernel function contains four different overload formats specified in Table 6.13.17.1.
int enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, void (^block)(void)) int enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, uint num_events_in_wait_list, clk_event_t event_wait_list, clk_event_t *event_ret, void (^block)(void)) int enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, void (^block)(local void, ...), uint size0, ...) int enqueue_kernel(queue_t queue, kernel_enqueue_flags_t flags, const ndrange_t ndrange, uint num_events_in_wait_list, clk_event_t event_wait_list, clk_event_t *event_ret, void (^block)(local void, ...), uint size0, ...)
Definition at line 372 of file SemaChecking.cpp.
References checkOpenCLBlockArgs(), checkOpenCLEnqueueVariadicArgs(), clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::QualType::getCanonicalType(), clang::CallExpr::getLocStart(), clang::CallExpr::getNumArgs(), clang::Type::getPointeeOrArrayElementType(), clang::Type::getPointeeType(), clang::BlockPointerType::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), isBlockPointer(), clang::Type::isClkEventT(), clang::Type::isIntegerType(), clang::Type::isNDRangeT(), clang::Type::isPointerType(), clang::Type::isQueueT(), clang::NumArgs, clang::ASTContext::OCLClkEventTy, clang::ASTContext::OCLNDRangeTy, and clang::ASTContext::OCLQueueTy.
OpenCL C v2.0, s6.13.17.6 - Check the argument to the get_kernel_work_group_size and get_kernel_preferred_work_group_size_multiple builtin functions.
Definition at line 306 of file SemaChecking.cpp.
References checkArgCount(), checkOpenCLBlockArgs(), clang::Sema::Diag(), clang::CallExpr::getArg(), and isBlockPointer().
Definition at line 683 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::Diag(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::CallExpr::getLocStart(), clang::CallExpr::getNumArgs(), clang::ASTContext::getPointerType(), clang::ASTContext::getQualifiedType(), clang::Expr::getType(), clang::LangAS::opencl_constant, clang::LangAS::opencl_global, clang::LangAS::opencl_local, and clang::Expr::setType().
|
static |
Definition at line 5059 of file SemaChecking.cpp.
References clang::Type::getAs(), clang::IdentifierInfo::getName(), clang::ASTContext::IntTy, clang::QualType::isNull(), clang::ASTContext::LongTy, clang::Name, clang::ASTContext::UnsignedIntTy, and clang::ASTContext::UnsignedLongTy.