|
clang 22.0.0git
|
#include "CheckExprLifetime.h"#include "clang/AST/APValue.h"#include "clang/AST/ASTContext.h"#include "clang/AST/ASTDiagnostic.h"#include "clang/AST/Attr.h"#include "clang/AST/AttrIterator.h"#include "clang/AST/CharUnits.h"#include "clang/AST/Decl.h"#include "clang/AST/DeclBase.h"#include "clang/AST/DeclCXX.h"#include "clang/AST/DeclObjC.h"#include "clang/AST/DeclarationName.h"#include "clang/AST/EvaluatedExprVisitor.h"#include "clang/AST/Expr.h"#include "clang/AST/ExprCXX.h"#include "clang/AST/ExprObjC.h"#include "clang/AST/FormatString.h"#include "clang/AST/IgnoreExpr.h"#include "clang/AST/NSAPI.h"#include "clang/AST/NonTrivialTypeVisitor.h"#include "clang/AST/OperationKinds.h"#include "clang/AST/RecordLayout.h"#include "clang/AST/Stmt.h"#include "clang/AST/TemplateBase.h"#include "clang/AST/TemplateName.h"#include "clang/AST/Type.h"#include "clang/AST/TypeBase.h"#include "clang/AST/TypeLoc.h"#include "clang/AST/UnresolvedSet.h"#include "clang/Basic/AddressSpaces.h"#include "clang/Basic/Diagnostic.h"#include "clang/Basic/DiagnosticSema.h"#include "clang/Basic/IdentifierTable.h"#include "clang/Basic/LLVM.h"#include "clang/Basic/LangOptions.h"#include "clang/Basic/OpenCLOptions.h"#include "clang/Basic/OperatorKinds.h"#include "clang/Basic/PartialDiagnostic.h"#include "clang/Basic/SourceLocation.h"#include "clang/Basic/SourceManager.h"#include "clang/Basic/Specifiers.h"#include "clang/Basic/SyncScope.h"#include "clang/Basic/TargetInfo.h"#include "clang/Basic/TypeTraits.h"#include "clang/Lex/Lexer.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/Sema.h"#include "clang/Sema/SemaAMDGPU.h"#include "clang/Sema/SemaARM.h"#include "clang/Sema/SemaBPF.h"#include "clang/Sema/SemaDirectX.h"#include "clang/Sema/SemaHLSL.h"#include "clang/Sema/SemaHexagon.h"#include "clang/Sema/SemaLoongArch.h"#include "clang/Sema/SemaMIPS.h"#include "clang/Sema/SemaNVPTX.h"#include "clang/Sema/SemaObjC.h"#include "clang/Sema/SemaOpenCL.h"#include "clang/Sema/SemaPPC.h"#include "clang/Sema/SemaRISCV.h"#include "clang/Sema/SemaSPIRV.h"#include "clang/Sema/SemaSystemZ.h"#include "clang/Sema/SemaWasm.h"#include "clang/Sema/SemaX86.h"#include "llvm/ADT/APFloat.h"#include "llvm/ADT/APInt.h"#include "llvm/ADT/APSInt.h"#include "llvm/ADT/ArrayRef.h"#include "llvm/ADT/DenseMap.h"#include "llvm/ADT/FoldingSet.h"#include "llvm/ADT/STLExtras.h"#include "llvm/ADT/STLForwardCompat.h"#include "llvm/ADT/SmallBitVector.h"#include "llvm/ADT/SmallPtrSet.h"#include "llvm/ADT/SmallString.h"#include "llvm/ADT/SmallVector.h"#include "llvm/ADT/StringExtras.h"#include "llvm/ADT/StringRef.h"#include "llvm/ADT/StringSet.h"#include "llvm/ADT/StringSwitch.h"#include "llvm/Support/AtomicOrdering.h"#include "llvm/Support/Compiler.h"#include "llvm/Support/ConvertUTF.h"#include "llvm/Support/ErrorHandling.h"#include "llvm/Support/Format.h"#include "llvm/Support/Locale.h"#include "llvm/Support/MathExtras.h"#include "llvm/Support/SaveAndRestore.h"#include "llvm/Support/raw_ostream.h"#include "llvm/TargetParser/RISCVTargetParser.h"#include "llvm/TargetParser/Triple.h"#include <algorithm>#include <cassert>#include <cctype>#include <cstddef>#include <cstdint>#include <functional>#include <limits>#include <optional>#include <string>#include <tuple>#include <utility>#include "clang/Basic/Builtins.inc"Go to the source code of this file.
Macros | |
| #define | ATOMIC_BUILTIN(ID, TYPE, ATTRS) |
| #define | BUILTIN_ROW(x) |
Enumerations | |
| enum | AbsoluteValueKind { AVK_Integer , AVK_Floating , AVK_Complex } |
| enum class | MathCheck { NaN , Inf } |
Functions | |
| static constexpr unsigned short | combineFAPK (Sema::FormatArgumentPassingKind A, Sema::FormatArgumentPassingKind B) |
| static bool | checkBuiltinVerboseTrap (CallExpr *Call, Sema &S) |
| static bool | convertArgumentToType (Sema &S, Expr *&Value, QualType Ty) |
| static bool | BuiltinAnnotation (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. | |
| static bool | BuiltinMSVCAnnotation (Sema &S, CallExpr *TheCall) |
| static bool | BuiltinAddressof (Sema &S, CallExpr *TheCall) |
| Check that the argument to __builtin_addressof is a glvalue, and set the result type to the corresponding pointer type. | |
| static bool | BuiltinFunctionStart (Sema &S, CallExpr *TheCall) |
| Check that the argument to __builtin_function_start is a function. | |
| static bool | BuiltinPreserveAI (Sema &S, CallExpr *TheCall) |
| Check the number of arguments and set the result type to the argument type. | |
| static bool | BuiltinAlignment (Sema &S, CallExpr *TheCall, unsigned ID) |
| Check that the value argument for __builtin_is_aligned(value, alignment) and __builtin_aligned_{up,down}(value, alignment) is an integer or a pointer type (but not a function pointer) and that the alignment is a power-of-two. | |
| static bool | BuiltinOverflow (Sema &S, CallExpr *TheCall, unsigned BuiltinID) |
| static ExprResult | BuiltinDumpStruct (Sema &S, CallExpr *TheCall) |
| static bool | BuiltinCallWithStaticChain (Sema &S, CallExpr *BuiltinCall) |
| static bool | ProcessFormatStringLiteral (const Expr *FormatExpr, StringRef &FormatStrRef, size_t &StrLen, ASTContext &Context) |
| static bool | BuiltinSEHScopeCheck (Sema &SemaRef, CallExpr *TheCall, Scope::ScopeFlags NeededScopeFlags, unsigned DiagID) |
| static void | builtinAllocaAddrSpace (Sema &S, CallExpr *TheCall) |
| static bool | checkBuiltinInferAllocToken (Sema &S, CallExpr *TheCall) |
| static bool | checkPointerAuthEnabled (Sema &S, Expr *E) |
| static bool | checkPointerAuthKey (Sema &S, Expr *&Arg) |
| static std::pair< const ValueDecl *, CharUnits > | findConstantBaseAndOffset (Sema &S, Expr *E) |
| static bool | checkPointerAuthValue (Sema &S, Expr *&Arg, PointerAuthOpKind OpKind, bool RequireConstant=false) |
| static ExprResult | PointerAuthStrip (Sema &S, CallExpr *Call) |
| static ExprResult | PointerAuthBlendDiscriminator (Sema &S, CallExpr *Call) |
| static ExprResult | PointerAuthSignGenericData (Sema &S, CallExpr *Call) |
| static ExprResult | PointerAuthSignOrAuth (Sema &S, CallExpr *Call, PointerAuthOpKind OpKind, bool RequireConstant) |
| static ExprResult | PointerAuthAuthAndResign (Sema &S, CallExpr *Call) |
| static ExprResult | PointerAuthStringDiscriminator (Sema &S, CallExpr *Call) |
| static ExprResult | GetVTablePointer (Sema &S, CallExpr *Call) |
| static ExprResult | BuiltinLaunder (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinIsWithinLifetime (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinTriviallyRelocate (Sema &S, CallExpr *TheCall) |
| static bool | CheckBuiltinTargetNotInUnsupported (Sema &S, unsigned BuiltinID, CallExpr *TheCall, ArrayRef< llvm::Triple::ObjectFormatType > UnsupportedObjectFormatTypes) |
| static bool | CheckBuiltinTargetInSupported (Sema &S, CallExpr *TheCall, ArrayRef< llvm::Triple::ArchType > SupportedArchs) |
| static void | CheckNonNullArgument (Sema &S, const Expr *ArgExpr, SourceLocation CallSiteLoc) |
| static bool | isValidMathElementType (QualType T) |
| static bool | checkMathBuiltinElementType (Sema &S, SourceLocation Loc, QualType ArgTy, Sema::EltwiseBuiltinArgTyRestriction ArgTyRestr, int ArgOrdinal) |
| static bool | BuiltinCpu (Sema &S, const TargetInfo &TI, CallExpr *TheCall, const TargetInfo *AuxTI, unsigned BuiltinID) |
| BuiltinCpu{Supports|Is} - Handle __builtin_cpu_{supports|is}(char *). | |
| static bool | BuiltinBswapg (Sema &S, CallExpr *TheCall) |
| Checks that __builtin_bswapg was called with a single argument, which is an unsigned integer, and overrides the return value type to the integer type. | |
| static bool | BuiltinPopcountg (Sema &S, CallExpr *TheCall) |
| Checks that __builtin_popcountg was called with a single argument, which is an unsigned integer. | |
| static bool | BuiltinCountZeroBitsGeneric (Sema &S, CallExpr *TheCall) |
| Checks that __builtin_{clzg,ctzg} was called with a first argument, which is an unsigned integer, and an optional second argument, which is promoted to an 'int'. | |
| static bool | CheckMaskedBuiltinArgs (Sema &S, Expr *MaskArg, Expr *PtrArg, unsigned Pos, bool AllowConst, bool AllowAS) |
| static bool | ConvertMaskedBuiltinArgs (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinMaskedLoad (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinMaskedStore (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinMaskedGather (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinMaskedScatter (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinInvoke (Sema &S, CallExpr *TheCall) |
| static ExprResult | BuiltinVectorMathConversions (Sema &S, Expr *E) |
| static bool | CheckNonNullExpr (Sema &S, const Expr *Expr) |
| Checks if a the given expression evaluates to null. | |
| static bool | isNonNullType (QualType type) |
| Determine whether the given type has a non-null nullability annotation. | |
| 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. | |
| static bool | checkVAStartABI (Sema &S, unsigned BuiltinID, Expr *Fn) |
| Check that the user is calling the appropriate va_start builtin for the target and calling convention. | |
| static bool | checkVAStartIsInVariadicFunction (Sema &S, Expr *Fn, ParmVarDecl **LastParam=nullptr) |
| static bool | IsShiftedByte (llvm::APSInt Value) |
| static void | sumOffsets (llvm::APSInt &Offset, llvm::APSInt Addend, BinaryOperatorKind BinOpKind, bool AddendIsRight) |
| static void | CheckFormatString (Sema &S, const FormatStringLiteral *FExpr, const StringLiteral *ReferenceFormatString, const Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, FormatStringType Type, bool inFunctionCall, VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, bool IgnoreStringsWithoutSpecifiers) |
| static const Expr * | maybeConstEvalStringLiteral (ASTContext &Context, const Expr *E) |
| static StringLiteralCheckType | checkFormatStringExpr (Sema &S, const StringLiteral *ReferenceFormatString, const Expr *E, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, FormatStringType Type, VariadicCallType CallType, bool InFunctionCall, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, std::optional< unsigned > *CallerFormatParamIdx=nullptr, bool IgnoreStringsWithoutSpecifiers=false) |
| static bool | CheckMissingFormatAttribute (Sema *S, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, StringLiteral *ReferenceFormatString, unsigned FormatIdx, unsigned FirstDataArg, FormatStringType FormatType, unsigned CallerParamIdx, SourceLocation Loc) |
| static bool | isInvalidOSLogArgTypeForCodeGen (FormatStringType FSType, QualType T) |
| 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 bool | isArithmeticArgumentPromotion (Sema &S, const ImplicitCastExpr *ICE) |
Return true if ICE is an implicit argument promotion of an arithmetic type. | |
| static analyze_format_string::ArgType::MatchKind | handleFormatSignedness (analyze_format_string::ArgType::MatchKind Match, DiagnosticsEngine &Diags, SourceLocation Loc) |
| static bool | CompareFormatSpecifiers (Sema &S, const StringLiteral *Ref, ArrayRef< EquatableFormatArgument > RefArgs, const StringLiteral *Fmt, ArrayRef< EquatableFormatArgument > FmtArgs, const Expr *FmtExpr, bool InFunctionCall) |
| 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) |
| template<std::size_t StrLen> | |
| static bool | IsStdFunction (const FunctionDecl *FDecl, const char(&Str)[StrLen]) |
| static bool | IsInfOrNanFunction (StringRef calleeName, MathCheck Check) |
| static bool | IsInfinityFunction (const FunctionDecl *FDecl) |
| static bool | CheckMemorySizeofForComparison (Sema &S, const Expr *E, const 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. | |
| 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). | |
| static const UnaryExprOrTypeTraitExpr * | getAsSizeOfExpr (const Expr *E) |
| static const Expr * | getSizeOfExprArg (const Expr *E) |
| If E is a sizeof expression, returns its argument expression, otherwise returns NULL. | |
| static QualType | getSizeOfArgType (const Expr *E) |
| If E is a sizeof expression, returns its argument type. | |
| static bool | doesExprLikelyComputeSize (const Expr *SizeofExpr) |
Detect if SizeofExpr is likely to calculate the sizeof an object. | |
| static bool | isArgumentExpandedFromMacro (SourceManager &SM, SourceLocation CallLoc, SourceLocation ArgLoc) |
| Check if the ArgLoc originated from a macro passed to the call at CallLoc. | |
| static void | CheckMemaccessSize (Sema &S, unsigned BId, const CallExpr *Call) |
| Diagnose cases like 'memset(buf, sizeof(buf), 0)', which should have the last two arguments transposed. | |
| 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. | |
| static const Expr * | getStrlenExprArg (const Expr *E) |
| static IntRange | GetValueRange (llvm::APSInt &value, unsigned MaxWidth) |
| static IntRange | GetValueRange (APValue &result, QualType Ty, unsigned MaxWidth) |
| static QualType | GetExprType (const Expr *E) |
| static std::optional< IntRange > | TryGetExprRange (ASTContext &C, const Expr *E, unsigned MaxWidth, bool InConstantContext, bool Approximate) |
| Attempts to estimate an approximate range for the given integer expression. | |
| static std::optional< IntRange > | TryGetExprRange (ASTContext &C, const Expr *E, bool InConstantContext, bool Approximate) |
| static bool | IsSameFloatAfterCast (const llvm::APFloat &value, const llvm::fltSemantics &Src, const llvm::fltSemantics &Tgt) |
| Checks whether the given value, which currently has the given source semantics, has the same value when coerced through the target semantics. | |
| static bool | IsSameFloatAfterCast (const APValue &value, const llvm::fltSemantics &Src, const llvm::fltSemantics &Tgt) |
| Checks whether the given value, which currently has the given source semantics, has the same value when coerced through the target semantics. | |
| static void | AnalyzeImplicitConversions (Sema &S, Expr *OrigE, SourceLocation CC, bool IsListInit) |
| AnalyzeImplicitConversions - Find and report any interesting implicit conversions in the given expression. | |
| static bool | IsEnumConstOrFromMacro (Sema &S, const Expr *E) |
| static bool | isKnownToHaveUnsignedValue (const Expr *E) |
| static bool | HasEnumType (const Expr *E) |
| static int | classifyConstantValue (Expr *Constant) |
| static bool | CheckTautologicalComparison (Sema &S, BinaryOperator *E, Expr *Constant, Expr *Other, const llvm::APSInt &Value, bool RhsConstant) |
| static void | AnalyzeImpConvsInComparison (Sema &S, BinaryOperator *E) |
| Analyze the operands of the given comparison. | |
| static void | AnalyzeComparison (Sema &S, BinaryOperator *E) |
| Implements -Wsign-compare. | |
| static bool | AnalyzeBitFieldAssignment (Sema &S, FieldDecl *Bitfield, Expr *Init, SourceLocation InitLoc) |
| Analyzes an attempt to assign the given value to a bitfield. | |
| static void | AnalyzeAssignment (Sema &S, BinaryOperator *E) |
| Analyze the given simple or compound assignment for warning-worthy operations. | |
| static void | DiagnoseImpCast (Sema &S, const Expr *E, QualType SourceType, QualType T, SourceLocation CContext, unsigned diag, bool PruneControlFlow=false) |
| Diagnose an implicit cast; purely a helper for CheckImplicitConversion. | |
| static void | DiagnoseImpCast (Sema &S, const Expr *E, QualType T, SourceLocation CContext, unsigned diag, bool PruneControlFlow=false) |
| Diagnose an implicit cast; purely a helper for CheckImplicitConversion. | |
| static void | DiagnoseFloatingImpCast (Sema &S, const Expr *E, QualType T, SourceLocation CContext) |
| Diagnose an implicit cast from a floating point value to an integer value. | |
| static void | AnalyzeCompoundAssignment (Sema &S, BinaryOperator *E) |
| Analyze the given compound assignment for the possible losing of floating-point precision. | |
| static std::string | PrettyPrintInRange (const llvm::APSInt &Value, IntRange Range) |
| static bool | IsImplicitBoolFloatConversion (Sema &S, const Expr *Ex, bool ToBool) |
| static void | CheckImplicitArgumentConversions (Sema &S, const CallExpr *TheCall, SourceLocation CC) |
| static void | DiagnoseNullConversion (Sema &S, Expr *E, QualType T, SourceLocation CC) |
| static bool | isSameWidthConstantConversion (Sema &S, Expr *E, QualType T, SourceLocation CC) |
| static const IntegerLiteral * | getIntegerLiteral (Expr *E) |
| static void | DiagnoseIntInBoolContext (Sema &S, Expr *E) |
| static void | DiagnoseMixedUnicodeImplicitConversion (Sema &S, const Type *Source, const Type *Target, Expr *E, QualType T, SourceLocation CC) |
| static void | CheckConditionalOperator (Sema &S, AbstractConditionalOperator *E, SourceLocation CC, QualType T) |
| static void | CheckConditionalOperand (Sema &S, Expr *E, QualType T, SourceLocation CC, bool &ICContext) |
| static void | CheckBoolLikeConversion (Sema &S, Expr *E, SourceLocation CC) |
| Check conversion of given expression to boolean. | |
| static void | CheckCommaOperand (Sema &S, Expr *E, QualType T, SourceLocation CC, bool ExtraCheckForImplicitConversion, llvm::SmallVectorImpl< AnalyzeImplicitConversionsWorkItem > &WorkList) |
| static void | AnalyzeImplicitConversions (Sema &S, AnalyzeImplicitConversionsWorkItem Item, llvm::SmallVectorImpl< AnalyzeImplicitConversionsWorkItem > &WorkList) |
| Data recursive variant of AnalyzeImplicitConversions. | |
| 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 std::optional< std::pair< CharUnits, CharUnits > > | getBaseAlignmentAndOffsetFromPtr (const Expr *E, ASTContext &Ctx) |
| This helper function takes a pointer expression and returns the alignment of a VarDecl and a constant offset from the VarDecl. | |
| static std::pair< CharUnits, CharUnits > | getDerivedToBaseAlignmentAndOffset (const CastExpr *CE, QualType DerivedType, CharUnits BaseAlignment, CharUnits Offset, ASTContext &Ctx) |
| Compute the alignment and offset of the base class object given the derived-to-base cast expression and the alignment and offset of the derived class object. | |
| static std::optional< std::pair< CharUnits, CharUnits > > | getAlignmentAndOffsetFromBinAddOrSub (const Expr *PtrE, const Expr *IntE, bool IsSub, ASTContext &Ctx) |
| Compute the alignment and offset of a binary additive operator. | |
| static std::optional< std::pair< CharUnits, CharUnits > > | getBaseAlignmentAndOffsetFromLValue (const Expr *E, ASTContext &Ctx) |
| This helper function takes an lvalue expression and returns the alignment of a VarDecl and a constant offset from the VarDecl. | |
| static CharUnits | getPresumedAlignmentOfPointer (const Expr *E, Sema &S) |
| 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) |
| static bool | ShouldDiagnoseEmptyStmtBody (const SourceManager &SourceMgr, SourceLocation StmtLoc, const NullStmt *Body) |
| static bool | isLayoutCompatible (const ASTContext &C, QualType T1, QualType T2) |
| Check if two types are layout-compatible in C++11 sense. | |
| static bool | isLayoutCompatible (const ASTContext &C, const EnumDecl *ED1, const EnumDecl *ED2) |
| Check if two enumeration types are layout-compatible. | |
| static bool | isLayoutCompatible (const ASTContext &C, const FieldDecl *Field1, const FieldDecl *Field2, bool AreUnionMembers=false) |
| Check if two fields are layout-compatible. | |
| static bool | isLayoutCompatibleStruct (const ASTContext &C, const RecordDecl *RD1, const RecordDecl *RD2) |
| Check if two standard-layout structs are layout-compatible. | |
| static bool | isLayoutCompatibleUnion (const ASTContext &C, const RecordDecl *RD1, const RecordDecl *RD2) |
| Check if two standard-layout unions are layout-compatible. | |
| static bool | isLayoutCompatible (const ASTContext &C, const RecordDecl *RD1, const RecordDecl *RD2) |
| static bool | FindTypeTagExpr (const Expr *TypeExpr, const ASTContext &Ctx, const ValueDecl **VD, uint64_t *MagicValue, bool isConstantEvaluated) |
| Given a type tag expression find the type tag itself. | |
| static bool | GetMatchingCType (const IdentifierInfo *ArgumentKind, const Expr *TypeExpr, const ASTContext &Ctx, const llvm::DenseMap< Sema::TypeTagMagicValue, Sema::TypeTagData > *MagicValues, bool &FoundWrongKind, Sema::TypeTagData &TypeInfo, bool isConstantEvaluated) |
| Retrieve the C type corresponding to type tag TypeExpr. | |
| static bool | IsSameCharType (QualType T1, QualType T2) |
| static bool | checkBuiltinVectorMathMixedEnums (Sema &S, Expr *LHS, Expr *RHS, SourceLocation Loc) |
| static bool | checkBuiltinVectorMathArgTypes (Sema &SemaRef, ArrayRef< Expr * > Args) |
| Check if all arguments have the same type. | |
| static std::optional< unsigned > | getAndVerifyMatrixDimension (Expr *Expr, StringRef Name, Sema &S) |
| #define ATOMIC_BUILTIN | ( | ID, | |
| TYPE, | |||
| ATTRS ) |
| #define BUILTIN_ROW | ( | x | ) |
| enum AbsoluteValueKind |
| Enumerator | |
|---|---|
| AVK_Integer | |
| AVK_Floating | |
| AVK_Complex | |
Definition at line 9666 of file SemaChecking.cpp.
|
strong |
| Enumerator | |
|---|---|
| NaN | |
| Inf | |
Definition at line 9877 of file SemaChecking.cpp.
|
static |
Analyze the given simple or compound assignment for warning-worthy operations.
Definition at line 12199 of file SemaChecking.cpp.
References AnalyzeBitFieldAssignment(), AnalyzeImplicitConversions(), clang::SemaBase::Diag(), clang::Stmt::getBeginLoc(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOperatorLoc(), clang::BinaryOperator::getRHS(), clang::Expr::getSourceBitField(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::Type::isAtomicType().
Referenced by AnalyzeImplicitConversions().
|
static |
Analyzes an attempt to assign the given value to a bitfield.
Returns true if there was something fishy about the attempt.
Definition at line 12040 of file SemaChecking.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Expr::EvaluateAsInt(), clang::Sema::findMacroSpelling(), clang::Type::getAsEnumDecl(), clang::Decl::getAttr(), clang::Stmt::getBeginLoc(), clang::FieldDecl::getBitWidth(), clang::FieldDecl::getBitWidthValue(), clang::Expr::getExprLoc(), clang::Sema::getLangOpts(), clang::Stmt::getSourceRange(), clang::TypeLoc::getSourceRange(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::TypeSourceInfo::getTypeLoc(), clang::DeclaratorDecl::getTypeSourceInfo(), clang::DeclaratorDecl::getTypeSpecStartLoc(), clang::Init, clang::FieldDecl::isBitField(), clang::Type::isBooleanType(), clang::SourceManager::isInSystemMacro(), clang::Decl::isInvalidDecl(), clang::Type::isSignedIntegerOrEnumerationType(), clang::Type::isSignedIntegerType(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), clang::Sema::LangOpts, clang::Expr::SE_AllowSideEffects, clang::Sema::SourceMgr, and toString().
Referenced by AnalyzeAssignment().
|
static |
Implements -Wsign-compare.
| E | the binary operator to check for warnings |
Definition at line 11919 of file SemaChecking.cpp.
References AnalyzeImpConvsInComparison(), AnalyzeImplicitConversions(), bool, CheckTautologicalComparison(), clang::Sema::Context, clang::Sema::DiagRuntimeBehavior(), clang::Expr::getIntegerConstantExpr(), clang::ASTContext::getIntWidth(), clang::Sema::getLangOpts(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOperatorLoc(), clang::BinaryOperator::getRHS(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ASTContext::hasSameUnqualifiedType(), clang::Type::hasSignedIntegerRepresentation(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::isConstantEvaluatedContext(), clang::BinaryOperator::isEqualityOp(), clang::Expr::isValueDependent(), clang::Other, clang::SemaBase::PDiag(), clang::T, and TryGetExprRange().
Referenced by AnalyzeImplicitConversions().
|
static |
Analyze the given compound assignment for the possible losing of floating-point precision.
Definition at line 12366 of file SemaChecking.cpp.
References AnalyzeImplicitConversions(), clang::cast(), clang::SemaBase::Diag(), DiagnoseImpCast(), clang::Type::getAs(), clang::Sema::getASTContext(), clang::BinaryOperator::getExprLoc(), clang::ASTContext::getFloatingTypeSemanticOrder(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOperatorLoc(), clang::BinaryOperator::getRHS(), clang::Expr::getType(), clang::isa(), clang::Type::isAtomicType(), clang::BuiltinType::isFloatingPoint(), clang::SourceManager::isInSystemMacro(), and clang::Sema::SourceMgr.
Referenced by AnalyzeImplicitConversions().
|
static |
Analyze the operands of the given comparison.
Implements the fallback case from AnalyzeComparison.
Definition at line 11911 of file SemaChecking.cpp.
References AnalyzeImplicitConversions(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOperatorLoc(), and clang::BinaryOperator::getRHS().
Referenced by AnalyzeComparison().
|
static |
Data recursive variant of AnalyzeImplicitConversions.
Subexpressions that should be visited are added to WorkList.
Analyze the given comma operator. The basic idea behind the analysis is to analyze the left and right operands slightly differently. The left operand needs to check whether the operand itself has an implicit conversion, but not whether the left operand induces an implicit conversion for the entire comma expression itself. This is similar to how CheckConditionalOperand behaves; it's as-if the correct operand were directly used for the implicit conversion check.
Definition at line 13252 of file SemaChecking.cpp.
References AnalyzeAssignment(), AnalyzeComparison(), AnalyzeCompoundAssignment(), clang::Call, CheckBoolLikeConversion(), CheckCommaOperand(), CheckConditionalOperator(), CheckImplicitArgumentConversions(), clang::Sema::CheckImplicitConversion(), clang::Stmt::children(), clang::Sema::Context, clang::FixItHint::CreateReplacement(), clang::SemaBase::Diag(), clang::Stmt::getBeginLoc(), clang::BinaryOperator::getExprLoc(), clang::Expr::getExprLoc(), clang::Sema::getLangOpts(), clang::BinaryOperator::getLHS(), clang::Lexer::getLocForEndOfToken(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Sema::getSourceManager(), clang::Stmt::getSourceRange(), clang::Lexer::getSourceText(), clang::CharSourceRange::getTokenRange(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::isa(), clang::Type::isAtomicType(), clang::BinaryOperator::isLogicalOp(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), clang::Type::isVoidType(), SM, and clang::T.
|
static |
AnalyzeImplicitConversions - Find and report any interesting implicit conversions in the given expression.
There are a couple of competing diagnostics here, -Wconversion and -Wsign-compare.
Definition at line 13463 of file SemaChecking.cpp.
References AnalyzeImplicitConversions().
Referenced by AnalyzeAssignment(), AnalyzeComparison(), AnalyzeCompoundAssignment(), AnalyzeImpConvsInComparison(), AnalyzeImplicitConversions(), CheckConditionalOperand(), and CheckConditionalOperator().
Check that the argument to __builtin_addressof is a glvalue, and set the result type to the corresponding pointer type.
Definition at line 269 of file SemaChecking.cpp.
References clang::Sema::CheckAddressOfOperand(), clang::Sema::checkArgCount(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::CallExpr::getBeginLoc(), clang::QualType::isNull(), clang::CallExpr::setArg(), and clang::Expr::setType().
Check that the value argument for __builtin_is_aligned(value, alignment) and __builtin_aligned_{up,down}(value, alignment) is an integer or a pointer type (but not a function pointer) and that the alignment is a power-of-two.
Definition at line 322 of file SemaChecking.cpp.
References clang::ASTContext::BoolTy, clang::Type::canDecayToPointerType(), clang::Sema::checkArgCount(), clang::Sema::Context, clang::SemaBase::Diag(), clang::Expr::EvaluateAsInt(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::ASTContext::getDecayedType(), clang::Expr::getExprLoc(), clang::APValue::getInt(), clang::ASTContext::getIntWidth(), clang::Expr::getType(), clang::InitializedEntity::InitializeParameter(), clang::Type::isArrayType(), clang::Type::isFunctionPointerType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isPointerType(), clang::Expr::isValueDependent(), clang::Sema::PerformCopyInitialization(), clang::Expr::SE_AllowSideEffects, clang::CallExpr::setArg(), clang::Expr::setType(), toString(), and clang::Expr::EvalResult::Val.
Definition at line 1495 of file SemaChecking.cpp.
References clang::Sema::Context, clang::ASTContext::getAddrSpaceQualType(), clang::Type::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::QualType::hasAddressSpace(), clang::Type::isPointerType(), clang::opencl_private, 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 219 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::SemaBase::Diag(), clang::CallExpr::getArg(), clang::Stmt::getBeginLoc(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::Type::isIntegerType(), and clang::Expr::setType().
Checks that __builtin_bswapg was called with a single argument, which is an unsigned integer, and overrides the return value type to the integer type.
Definition at line 2231 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Stmt::getBeginLoc(), clang::Expr::getType(), clang::Type::isIntegerType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Expr::isTypeDependent(), clang::CallExpr::setArg(), and clang::Expr::setType().
Definition at line 794 of file SemaChecking.cpp.
References clang::Call, clang::cast(), clang::Sema::checkArgCount(), clang::Sema::Context, clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::CallExpr::getBeginLoc(), clang::CallExpr::getCallee(), clang::ASTContext::getFunctionType(), clang::ASTContext::getPointerType(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::Expr::IgnoreImpCasts(), clang::Sema::ImpCastExprToType(), clang::isa(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isPointerType(), clang::CallExpr::setArg(), clang::CallExpr::setCallee(), clang::Expr::setObjectKind(), clang::Expr::setType(), clang::Expr::setValueKind(), and clang::Sema::UsualUnaryConversions().
Checks that __builtin_{clzg,ctzg} was called with a first argument, which is an unsigned integer, and an optional second argument, which is promoted to an 'int'.
Definition at line 2289 of file SemaChecking.cpp.
References clang::Sema::checkArgCountRange(), clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Stmt::getBeginLoc(), clang::CallExpr::getNumArgs(), clang::Expr::getType(), clang::Type::isExtVectorBoolType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isSpecificBuiltinType(), clang::Type::isUnsignedIntegerType(), clang::CallExpr::setArg(), and clang::Sema::UsualUnaryConversions().
|
static |
BuiltinCpu{Supports|Is} - Handle __builtin_cpu_{supports|is}(char *).
This checks that the target supports the builtin and that the string argument is constant and valid.
Definition at line 2187 of file SemaChecking.cpp.
References clang::cast(), clang::SemaBase::Diag(), Feature, clang::CallExpr::getArg(), clang::CallExpr::getBeginLoc(), clang::CallExpr::getEndLoc(), clang::Stmt::getSourceRange(), clang::TargetInfo::getTriple(), clang::Expr::IgnoreParenImpCasts(), clang::isa(), clang::TargetInfo::supportsCpuIs(), clang::TargetInfo::supportsCpuSupports(), clang::TargetInfo::validateCpuIs(), and clang::TargetInfo::validateCpuSupports().
|
static |
Definition at line 728 of file SemaChecking.cpp.
References clang::Sema::checkArgCountAtLeast(), clang::Sema::Context, clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Type::getAsRecordDecl(), clang::Stmt::getBeginLoc(), clang::CallExpr::getDirectCallee(), clang::Stmt::getEndLoc(), clang::Sema::getLangOpts(), clang::Sema::getLocForEndOfToken(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::Type::isBlockPointerType(), clang::Type::isFunctionPointerType(), clang::Type::isFunctionType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isPointerType(), clang::Type::isRecordType(), clang::Sema::RequireCompleteType(), and clang::CallExpr::setArg().
Check that the argument to __builtin_function_start is a function.
Definition at line 284 of file SemaChecking.cpp.
References clang::Sema::checkAddressOfFunctionIsAvailable(), clang::Sema::checkArgCount(), clang::Expr::containsErrors(), clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Expr::getAsBuiltinConstantDeclRef(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getSourceRange(), clang::ActionResult< PtrTy, Compress >::isInvalid(), and clang::CallExpr::setArg().
|
static |
Definition at line 2560 of file SemaChecking.cpp.
References clang::Sema::ActOnBinOp(), clang::Sema::ActOnCallExpr(), clang::Sema::ActOnMemberAccessExpr(), clang::Sema::ActOnUnaryOp(), clang::Sema::BuiltinIsBaseOf(), clang::Sema::BuiltinRemoveCVRef(), clang::Sema::checkArgCount(), clang::Sema::Context, clang::SemaBase::Diag(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::IdentifierTable::get(), clang::CallExpr::getArgs(), clang::Type::getAs(), clang::Type::getAsCXXRecordDecl(), clang::DeclarationName::getAsString(), clang::CallExpr::getBeginLoc(), clang::Sema::getCurScope(), clang::NamedDecl::getDeclName(), clang::CallExpr::getNumArgs(), clang::CallExpr::getRParenLoc(), clang::Stmt::getSourceRange(), clang::ASTContext::hasSameType(), clang::ASTContext::Idents, clang::Decl::isInStdNamespace(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Expr::isTypeDependent(), and clang::UnqualifiedId::setIdentifier().
|
static |
Definition at line 1954 of file SemaChecking.cpp.
References clang::ASTContext::BoolTy, clang::Sema::checkArgCount(), clang::Sema::Context, clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::SemaBase::Diag(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Expr::getExprLoc(), clang::Expr::getType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::CallExpr::setArg(), and clang::Expr::setType().
|
static |
Definition at line 1894 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::Sema::Context, clang::SemaBase::Diag(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Type::getAsArrayTypeUnsafe(), clang::CallExpr::getBeginLoc(), clang::Type::getPointeeType(), clang::ASTContext::getPointerType(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::InitializedEntity::InitializeParameter(), clang::Type::isFunctionPointerType(), clang::Type::isFunctionType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isObjectType(), clang::Type::isPointerType(), clang::Type::isVoidPointerType(), clang::Sema::PerformCopyInitialization(), clang::Sema::RequireCompleteType(), clang::CallExpr::setArg(), and clang::Expr::setType().
|
static |
Definition at line 2452 of file SemaChecking.cpp.
References clang::ASTContext::BuiltinInfo, clang::Sema::checkArgCountRange(), CheckMaskedBuiltinArgs(), clang::Sema::Context, ConvertMaskedBuiltinArgs(), clang::SemaBase::Diag(), clang::ExprError(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getBeginLoc(), clang::CallExpr::getBuiltinCallee(), clang::VectorType::getElementType(), clang::Expr::getExprLoc(), clang::ASTContext::getExtVectorType(), clang::CallExpr::getNumArgs(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::Builtin::Context::getQuotedName(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::ASTContext::hasSameType(), clang::Type::isExtVectorType(), clang::Type::isIntegerType(), clang::Expr::isTypeDependent(), and clang::Expr::setType().
|
static |
Definition at line 2374 of file SemaChecking.cpp.
References clang::Sema::checkArgCountRange(), CheckMaskedBuiltinArgs(), clang::Sema::Context, ConvertMaskedBuiltinArgs(), clang::SemaBase::Diag(), clang::ExprError(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::CallExpr::getBuiltinCallee(), clang::Expr::getExprLoc(), clang::ASTContext::getExtVectorType(), clang::CallExpr::getNumArgs(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::ASTContext::hasSameType(), clang::Expr::isTypeDependent(), and clang::Expr::setType().
|
static |
Definition at line 2502 of file SemaChecking.cpp.
References clang::ASTContext::BuiltinInfo, clang::Type::castAs(), clang::Sema::checkArgCount(), CheckMaskedBuiltinArgs(), clang::Sema::Context, ConvertMaskedBuiltinArgs(), clang::SemaBase::Diag(), clang::ExprError(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getBeginLoc(), clang::CallExpr::getBuiltinCallee(), clang::CallExpr::getDirectCallee(), clang::VectorType::getElementType(), clang::Stmt::getEndLoc(), clang::ASTContext::getExtVectorType(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::Builtin::Context::getQuotedName(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::ASTContext::hasSameType(), clang::Type::isExtVectorType(), clang::Type::isIntegerType(), clang::Expr::isTypeDependent(), clang::Expr::setType(), and clang::ASTContext::VoidTy.
|
static |
Definition at line 2410 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), CheckMaskedBuiltinArgs(), clang::Sema::Context, ConvertMaskedBuiltinArgs(), clang::SemaBase::Diag(), clang::ExprError(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::CallExpr::getBeginLoc(), clang::Stmt::getBeginLoc(), clang::CallExpr::getBuiltinCallee(), clang::CallExpr::getDirectCallee(), clang::Stmt::getEndLoc(), clang::Expr::getExprLoc(), clang::ASTContext::getExtVectorType(), clang::VectorType::getNumElements(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::ASTContext::hasSameType(), clang::Expr::isTypeDependent(), clang::Type::isVectorType(), clang::Expr::setType(), and clang::ASTContext::VoidTy.
Definition at line 245 of file SemaChecking.cpp.
References clang::CallExpr::arguments(), clang::SemaBase::Diag(), clang::CallExpr::getCallee(), clang::CallExpr::getEndLoc(), clang::CallExpr::getNumArgs(), and clang::Stmt::getSourceRange().
Definition at line 400 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Type::getAs(), clang::Sema::getASTContext(), clang::Stmt::getBeginLoc(), clang::Expr::getExprLoc(), clang::Lexer::getImmediateMacroName(), clang::ASTContext::getIntWidth(), clang::Sema::getLangOpts(), clang::Type::getPointeeType(), clang::Sema::getSourceManager(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::Type::isIntegerType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::SourceLocation::isMacroID(), and clang::CallExpr::setArg().
Checks that __builtin_popcountg was called with a single argument, which is an unsigned integer.
Definition at line 2264 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::Stmt::getBeginLoc(), clang::Expr::getType(), clang::Type::isExtVectorBoolType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Type::isUnsignedIntegerType(), and clang::CallExpr::setArg().
Check the number of arguments and set the result type to the argument type.
Definition at line 311 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::CallExpr::getArg(), clang::Expr::getType(), and clang::Expr::setType().
|
static |
Definition at line 1471 of file SemaChecking.cpp.
References clang::cast(), clang::SemaBase::Diag(), clang::CallExpr::getCallee(), clang::Sema::getCurScope(), clang::Expr::getExprLoc(), clang::Scope::getFlags(), clang::Scope::getParent(), clang::Expr::IgnoreParenCasts(), clang::Sema::inTemplateInstantiation(), and clang::Scope::isSEHExceptScope().
|
static |
Definition at line 1991 of file SemaChecking.cpp.
References clang::Sema::checkArgCount(), clang::Sema::DefaultLvalueConversion(), clang::SemaBase::Diag(), clang::ExprError(), clang::CallExpr::getArg(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::QualType::getCanonicalType(), clang::QualType::getCVRQualifiers(), clang::Expr::getExprLoc(), clang::Type::getPointeeType(), clang::ASTContext::getSizeType(), clang::Expr::getType(), clang::Sema::IsCXXTriviallyRelocatableType(), clang::Type::isPointerType(), clang::Sema::RequireCompleteType(), clang::CallExpr::setArg(), clang::Expr::setType(), clang::T, and clang::Sema::tryConvertExprToType().
|
static |
Definition at line 2655 of file SemaChecking.cpp.
References clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::ActionResult< PtrTy, Compress >::isInvalid(), and clang::Sema::UsualUnaryFPConversions().
Referenced by clang::Sema::BuiltinElementwiseTernaryMath(), clang::Sema::BuiltinVectorMath(), and clang::Sema::PrepareBuiltinElementwiseMathOneArgCall().
|
static |
Definition at line 9685 of file SemaChecking.cpp.
References AVK_Complex, AVK_Floating, and AVK_Integer.
|
static |
Check conversion of given expression to boolean.
Input argument E is a logical expression.
Definition at line 13220 of file SemaChecking.cpp.
References clang::ASTContext::BoolTy, clang::Sema::CheckImplicitConversion(), clang::Sema::Context, clang::Sema::getLangOpts(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::Type::isAtomicType().
Referenced by AnalyzeImplicitConversions().
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 4937 of file SemaChecking.cpp.
References clang::Sema::Context, clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::InitializedEntity::InitializeParameter(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Sema::PerformCopyInitialization(), and clang::CallExpr::setArg().
Definition at line 1505 of file SemaChecking.cpp.
References clang::CallExpr::arguments(), clang::Sema::checkArgCountAtLeast(), clang::Sema::Context, clang::SemaBase::Diag(), clang::ASTContext::getSizeType(), clang::Type::isVoidType(), and clang::Expr::setType().
|
static |
Definition at line 2058 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getSourceRange(), clang::ASTContext::getTargetInfo(), and clang::TargetInfo::getTriple().
|
static |
Definition at line 2042 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), clang::Sema::getASTContext(), clang::CallExpr::getBeginLoc(), clang::Stmt::getSourceRange(), clang::ASTContext::getTargetInfo(), and clang::TargetInfo::getTriple().
Check if all arguments have the same type.
If the types don't match, emit an error message and return true. Otherwise return false.
For scalars we directly compare their unqualified types. But even if we compare unqualified vector types, a difference in qualifiers in the element types can make the vector types be considered not equal. For example, vector of 4 'const float' values vs vector of 4 'float' values. So we compare unqualified types of their elements and number of elements.
Definition at line 16323 of file SemaChecking.cpp.
References clang::Type::castAs(), clang::Sema::Context, clang::SemaBase::Diag(), clang::Stmt::getBeginLoc(), clang::Expr::getType(), clang::ASTContext::hasSameUnqualifiedType(), and clang::Type::isVectorType().
Referenced by clang::Sema::BuiltinElementwiseTernaryMath(), and clang::Sema::BuiltinVectorMath().
|
static |
Definition at line 16302 of file SemaChecking.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Expr::getEnumCoercedType(), clang::Stmt::getSourceRange(), clang::ASTContext::hasSameUnqualifiedType(), and clang::Type::isUnscopedEnumerationType().
Referenced by clang::Sema::BuiltinElementwiseTernaryMath(), and clang::Sema::BuiltinVectorMath().
Definition at line 178 of file SemaChecking.cpp.
References clang::Call, clang::Sema::Context, and clang::SemaBase::Diag().
|
static |
Definition at line 13239 of file SemaChecking.cpp.
References clang::Sema::CheckImplicitConversion(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::T.
Referenced by AnalyzeImplicitConversions().
|
static |
Definition at line 13168 of file SemaChecking.cpp.
References AnalyzeImplicitConversions(), CheckConditionalOperator(), clang::Sema::CheckImplicitConversion(), clang::Sema::getLangOpts(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::Type::isRecordType(), clang::Sema::RequireCompleteExprType(), and clang::T.
Referenced by CheckConditionalOperator().
|
static |
Definition at line 13183 of file SemaChecking.cpp.
References AnalyzeImplicitConversions(), CheckConditionalOperand(), clang::Sema::CheckImplicitConversion(), DiagnoseIntInBoolContext(), clang::Sema::Diags, clang::AbstractConditionalOperator::getCond(), clang::AbstractConditionalOperator::getFalseExpr(), clang::AbstractConditionalOperator::getQuestionLoc(), clang::AbstractConditionalOperator::getTrueExpr(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::DiagnosticsEngine::isIgnored(), and clang::T.
Referenced by AnalyzeImplicitConversions(), and CheckConditionalOperand().
|
static |
Definition at line 9401 of file SemaChecking.cpp.
References clang::Sema::CheckFormatStringsCompatible(), clang::Sema::Context, clang::FreeBSDKPrintf, clang::ASTContext::getAsConstantArrayType(), clang::Sema::getLangOpts(), clang::Stmt::getSourceRange(), clang::ASTContext::getTargetInfo(), clang::Kprintf, clang::NSString, clang::OSLog, clang::OSTrace, clang::analyze_format_string::parseFormatStringHasFormattingSpecifiers(), clang::analyze_format_string::ParsePrintfString(), clang::analyze_format_string::ParseScanfString(), clang::SemaBase::PDiag(), clang::Printf, clang::Scanf, and clang::T.
Referenced by checkFormatStringExpr().
|
static |
Definition at line 6617 of file SemaChecking.cpp.
References clang::Sema::FormatStringInfo::ArgPassingKind, clang::C, clang::cast(), CheckFormatString(), checkFormatStringExpr(), combineFAPK(), clang::Cond, clang::Sema::Context, clang::SemaBase::Diag(), clang::Expr::EvaluateAsInt(), clang::Sema::FAPK_Fixed, clang::Sema::FAPK_VAList, clang::Sema::FAPK_Variadic, clang::Sema::FormatStringInfo::FormatIdx, clang::CallExpr::getArg(), clang::ASTContext::getAsArrayType(), clang::Sema::getASTContext(), clang::Stmt::getBeginLoc(), clang::FunctionDecl::getBuiltinID(), clang::CallExpr::getCalleeDecl(), clang::DeclRefExpr::getDecl(), clang::Sema::getFormatStringInfo(), clang::Sema::GetFormatStringType(), clang::Sema::GetFormatStringTypeName(), clang::NamedDecl::getIdentifier(), clang::APValue::getInt(), clang::StringLiteral::getLength(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::StringLiteral::getString(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::Init, clang::BinaryOperator::isAdditiveOp(), clang::Sema::isConstantEvaluatedContext(), IsFirst, clang::Expr::isNullPointerConstant(), clang::IdentifierInfo::isStr(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), maybeConstEvalStringLiteral(), clang::Expr::NPC_ValueDependentIsNotNull, clang::Expr::SE_NoSideEffects, sumOffsets(), clang::T, and clang::Expr::EvalResult::Val.
Referenced by checkFormatStringExpr().
|
static |
Definition at line 13473 of file SemaChecking.cpp.
References clang::Call, clang::Sema::Context, clang::SemaBase::Diag(), clang::DeclRefExpr::getDecl(), clang::Expr::getExprLoc(), clang::Decl::getLocation(), clang::ValueDecl::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::Type::isReferenceType().
Referenced by clang::Sema::DiagnoseAlwaysNonNullPointer().
|
static |
Definition at line 12432 of file SemaChecking.cpp.
References DiagnoseImpCast(), clang::CallExpr::getArg(), clang::CallExpr::getNumArgs(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), and IsImplicitBoolFloatConversion().
Referenced by AnalyzeImplicitConversions().
|
static |
Definition at line 2329 of file SemaChecking.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::QualType::getAtomicUnqualifiedType(), clang::Stmt::getBeginLoc(), clang::Expr::getExprLoc(), clang::Type::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::QualType::hasAddressSpace(), clang::Type::isAtomicType(), clang::QualType::isConstQualified(), clang::Type::isExtVectorBoolType(), and clang::QualType::isVolatileQualified().
Referenced by BuiltinMaskedGather(), BuiltinMaskedLoad(), BuiltinMaskedScatter(), and BuiltinMaskedStore().
|
static |
Definition at line 2143 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), clang::Sema::FloatTy, clang::Type::getAs(), clang::Sema::IntegerTy, clang::Type::isIntegerType(), clang::Type::isRealFloatingType(), clang::Type::isUnsignedIntegerType(), isValidMathElementType(), clang::Sema::None, and clang::Sema::SignedIntOrFloatTy.
Referenced by clang::Sema::BuiltinElementwiseTernaryMath(), clang::Sema::BuiltinVectorMath(), and clang::Sema::PrepareBuiltinElementwiseMathOneArgCall().
Diagnose cases like 'memset(buf, sizeof(buf), 0)', which should have the last two arguments transposed.
Definition at line 10296 of file SemaChecking.cpp.
References clang::Call, clang::cast(), clang::SemaBase::Diag(), doesExprLikelyComputeSize(), clang::Expr::getExprLoc(), clang::Lexer::getImmediateMacroName(), clang::Sema::getLangOpts(), clang::Sema::getSourceManager(), clang::isa(), isArgumentExpandedFromMacro(), clang::SourceLocation::isMacroID(), and SM.
|
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 10082 of file SemaChecking.cpp.
References clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), clang::SemaBase::Diag(), clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and clang::Sema::getLocForEndOfToken().
|
static |
Definition at line 7116 of file SemaChecking.cpp.
References clang::Decl::addAttr(), clang::cast(), clang::FixItHint::CreateInsertion(), clang::Sema::CurContext, clang::SemaBase::Diag(), clang::Sema::FAPK_Elsewhere, clang::Sema::FAPK_Fixed, clang::Sema::FAPK_VAList, clang::Sema::FAPK_Variadic, clang::IdentifierTable::get(), clang::Sema::getASTContext(), clang::Decl::getBeginLoc(), clang::Sema::getDiagnostics(), clang::Decl::getEndLoc(), clang::Sema::GetFormatStringTypeName(), clang::getFunctionOrMethodNumParams(), clang::Sema::getLangOpts(), clang::Decl::getLocation(), clang::StringLiteral::getString(), clang::hasImplicitObjectParameter(), clang::ASTContext::Idents, clang::isa(), clang::isFunctionOrMethodVariadic(), and clang::DiagnosticsEngine::isIgnored().
|
static |
Definition at line 3714 of file SemaChecking.cpp.
References CheckNonNullExpr(), clang::Sema::DiagRuntimeBehavior(), clang::Stmt::getSourceRange(), and clang::SemaBase::PDiag().
Referenced by clang::Sema::BuildAtomicExpr(), and CheckNonNullArguments().
|
static |
Definition at line 3731 of file SemaChecking.cpp.
References clang::cast(), CheckNonNullArgument(), clang::FunctionProtoType::getParamTypes(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::isa(), clang::Sema::isConstantEvaluatedContext(), isNonNullType(), clang::Sema::isValidPointerAttrType(), clang::NonNull, clang::FunctionDecl::parameters(), clang::ast_matchers::pointerType, clang::Decl::specific_attrs(), and clang::ast_matchers::type.
Referenced by clang::Sema::checkCall().
Checks if a the given expression evaluates to null.
Returns true if the value evaluates to null.
Definition at line 3683 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Expr::EvaluateAsBooleanCondition(), clang::Type::getAsUnionType(), clang::Type::getNullability(), clang::Expr::getType(), clang::IgnoreElidableImplicitConstructorSingleStep(), clang::IgnoreExprNodes(), clang::Expr::IgnoreImplicit(), clang::IgnoreImplicitAsWrittenSingleStep(), clang::isa(), clang::Expr::isValueDependent(), and clang::NonNull.
Referenced by CheckNonNullArgument().
Definition at line 1543 of file SemaChecking.cpp.
References clang::Sema::checkPointerAuthEnabled(), clang::Expr::getExprLoc(), and clang::Stmt::getSourceRange().
Referenced by PointerAuthAuthAndResign(), PointerAuthBlendDiscriminator(), PointerAuthSignGenericData(), PointerAuthSignOrAuth(), PointerAuthStringDiscriminator(), and PointerAuthStrip().
Definition at line 1547 of file SemaChecking.cpp.
References clang::Sema::checkConstantPointerAuthKey(), clang::Sema::Context, convertArgumentToType(), clang::ASTContext::IntTy, and clang::Expr::isValueDependent().
Referenced by PointerAuthAuthAndResign(), PointerAuthSignOrAuth(), and PointerAuthStrip().
|
static |
Definition at line 1643 of file SemaChecking.cpp.
References clang::Call, clang::Sema::CheckPlaceholderExpr(), clang::Sema::Context, convertArgumentToType(), clang::SemaBase::Diag(), findConstantBaseAndOffset(), clang::ActionResult< PtrTy, Compress >::get(), clang::Expr::getExprLoc(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::ASTContext::getUIntPtrType(), clang::QualType::getUnqualifiedType(), clang::Expr::hasPlaceholderType(), clang::Expr::IgnoreParens(), Integer, clang::Invalid, clang::isa(), clang::Type::isIntegralOrUnscopedEnumerationType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Expr::isNullPointerConstant(), clang::Type::isNullPtrType(), clang::Type::isPointerType(), clang::Expr::NPC_ValueDependentIsNull, Pointer, and clang::ASTContext::VoidPtrTy.
Referenced by PointerAuthAuthAndResign(), PointerAuthBlendDiscriminator(), PointerAuthSignGenericData(), PointerAuthSignOrAuth(), and PointerAuthStrip().
|
static |
Definition at line 11755 of file SemaChecking.cpp.
References clang::ASTContext::CharTy, classifyConstantValue(), clang::Sema::Context, clang::SemaBase::Diag(), Diag(), clang::Sema::DiagRuntimeBehavior(), clang::Type::getAs(), clang::Sema::getLangOpts(), clang::BinaryOperator::getLHS(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getOpcodeStr(), clang::BinaryOperator::getOperatorLoc(), clang::BinaryOperator::getRHS(), clang::Stmt::getSourceRange(), clang::Expr::getType(), HasEnumType(), clang::ASTContext::hasSameUnqualifiedType(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::inTemplateInstantiation(), clang::Type::isBooleanType(), clang::Sema::isConstantEvaluatedContext(), IsEnumConstOrFromMacro(), clang::Type::isEnumeralType(), isKnownToHaveUnsignedValue(), clang::Type::isSpecificBuiltinType(), clang::SemaObjC::NSAPIObj, clang::Sema::ObjC(), clang::Other, clang::SemaBase::PDiag(), TryGetExprRange(), and clang::QualType::withoutLocalFastQualifiers().
Referenced by AnalyzeComparison().
|
static |
Definition at line 15338 of file SemaChecking.cpp.
References clang::SemaObjC::CheckLiteralKind(), clang::SemaBase::Diag(), clang::Stmt::getSourceRange(), clang::Expr::IgnoreParenImpCasts(), clang::SemaObjC::LK_None, clang::SemaObjC::LK_String, and clang::Sema::ObjC().
Referenced by checkUnsafeAssignObject().
|
static |
Definition at line 15359 of file SemaChecking.cpp.
References clang::cast(), checkUnsafeAssignLiteral(), clang::SemaBase::Diag(), clang::Stmt::getSourceRange(), clang::Qualifiers::OCL_ExplicitNone, and clang::Qualifiers::OCL_Weak.
Referenced by clang::Sema::checkUnsafeAssigns(), and clang::Sema::checkUnsafeExprAssigns().
Check that the user is calling the appropriate va_start builtin for the target and calling convention.
Definition at line 5425 of file SemaChecking.cpp.
References clang::Type::castAs(), clang::CC_C, clang::CC_Win64, clang::CC_X86_64SysV, clang::Sema::Context, clang::SemaBase::Diag(), clang::Sema::getCurFunctionDecl(), clang::ASTContext::getTargetInfo(), clang::TargetInfo::getTriple(), and clang::ValueDecl::getType().
|
static |
Definition at line 5460 of file SemaChecking.cpp.
References clang::Block, clang::Sema::CurContext, clang::SemaBase::Diag(), clang::isa(), clang::FunctionDecl::isVariadic(), clang::nullptr, and clang::FunctionDecl::parameters().
Definition at line 11741 of file SemaChecking.cpp.
Referenced by CheckTautologicalComparison().
|
staticconstexpr |
Definition at line 130 of file SemaChecking.cpp.
Referenced by checkFormatStringExpr().
|
static |
Definition at line 9343 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), clang::Stmt::getBeginLoc(), clang::StringLiteral::getBeginLoc(), clang::Stmt::getSourceRange(), and clang::SemaBase::PDiag().
Referenced by clang::Sema::CheckFormatStringsCompatible().
Definition at line 203 of file SemaChecking.cpp.
References clang::Sema::Context, clang::InitializedEntity::InitializeParameter(), and clang::Sema::PerformCopyInitialization().
Referenced by checkPointerAuthKey(), and checkPointerAuthValue().
Definition at line 2358 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::ASTContext::DependentTy, clang::ActionResult< PtrTy, Compress >::get(), clang::CallExpr::getArg(), clang::CallExpr::getNumArgs(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::Expr::isTypeDependent(), clang::CallExpr::setArg(), and clang::Expr::setType().
Referenced by BuiltinMaskedGather(), BuiltinMaskedLoad(), BuiltinMaskedScatter(), and BuiltinMaskedStore().
|
static |
Definition at line 8345 of file SemaChecking.cpp.
References clang::LookupResult::begin(), clang::Sema::Context, clang::ast_matchers::decl, clang::LookupResult::end(), clang::IdentifierTable::get(), clang::Type::getAsCXXRecordDecl(), clang::ASTContext::Idents, clang::TagDecl::isBeingDefined(), clang::TagDecl::isCompleteDefinition(), clang::Sema::LookupMemberName, clang::Sema::LookupQualifiedName(), and clang::LookupResult::suppressDiagnostics().
Referenced by clang::Sema::hasCStrMethod().
|
static |
Definition at line 14675 of file SemaChecking.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), diagnoseArrayStarInParamType(), clang::ASTContext::getAsArrayType(), clang::ArrayType::getElementType(), clang::ArrayType::getSizeModifier(), clang::Type::isVariablyModifiedType(), and clang::Star.
Referenced by clang::Sema::CheckParmsForFunctionDef(), and diagnoseArrayStarInParamType().
|
static |
Diagnose an implicit cast from a floating point value to an integer value.
Definition at line 12252 of file SemaChecking.cpp.
References clang::SemaObjC::adornBoolConversionDiagWithTernaryFixit(), clang::Sema::Context, clang::SemaBase::Diag(), DiagnoseImpCast(), clang::Sema::DiagRuntimeBehavior(), clang::Expr::EvaluateAsFloat(), clang::Expr::getExprLoc(), clang::ASTContext::getIntWidth(), clang::Stmt::getSourceRange(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::Sema::inTemplateInstantiation(), clang::isa(), clang::SemaObjC::isSignedCharBool(), clang::Sema::ObjC(), clang::SemaBase::PDiag(), clang::Expr::SE_AllowSideEffects, and clang::T.
Referenced by clang::Sema::CheckImplicitConversion().
|
static |
Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
Definition at line 12222 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), clang::Sema::DiagRuntimeBehavior(), clang::Sema::getASTContext(), clang::Expr::getExprLoc(), clang::Stmt::getSourceRange(), clang::QualType::hasAddressSpace(), clang::SemaBase::PDiag(), clang::ASTContext::removeAddrSpaceQualType(), and clang::T.
Referenced by AnalyzeCompoundAssignment(), CheckImplicitArgumentConversions(), clang::Sema::CheckImplicitConversion(), DiagnoseFloatingImpCast(), DiagnoseImpCast(), and DiagnoseMixedUnicodeImplicitConversion().
|
static |
Diagnose an implicit cast; purely a helper for CheckImplicitConversion.
Definition at line 12245 of file SemaChecking.cpp.
References DiagnoseImpCast(), clang::Expr::getType(), and clang::T.
Definition at line 12538 of file SemaChecking.cpp.
References clang::Sema::Context, clang::FixItHint::CreateInsertion(), clang::SemaBase::Diag(), clang::Expr::EvaluateAsInt(), clang::Stmt::getBeginLoc(), clang::Stmt::getEndLoc(), clang::Expr::getExprLoc(), getIntegerLiteral(), clang::Sema::getLocForEndOfToken(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::Type::isSignedIntegerType(), clang::Expr::isValueDependent(), and clang::Expr::SE_AllowSideEffects.
Referenced by CheckConditionalOperator(), and clang::Sema::CheckImplicitConversion().
|
static |
Definition at line 12578 of file SemaChecking.cpp.
References clang::SemaBase::Diag(), DiagnoseImpCast(), clang::Expr::EvaluateAsInt(), clang::FormatUTFCodeUnitAsCodepoint(), clang::Sema::getASTContext(), clang::ASTContext::getIntWidth(), clang::Expr::getType(), clang::QualType::getUnqualifiedType(), clang::Sema::isConstantEvaluatedContext(), clang::Expr::SE_AllowSideEffects, and clang::T.
Referenced by clang::Sema::CheckImplicitConversion().
|
static |
Definition at line 12452 of file SemaChecking.cpp.
References clang::FixItHint::CreateReplacement(), clang::SemaBase::Diag(), clang::Sema::Diags, clang::CharSourceRange::getBegin(), clang::SourceRange::getBegin(), clang::Expr::getExprLoc(), clang::SourceManager::getFileID(), clang::Sema::getFixItZeroLiteralForType(), clang::SourceManager::getImmediateExpansionRange(), clang::Lexer::getImmediateMacroNameForDiagnostics(), clang::Sema::getLangOpts(), clang::Stmt::getSourceRange(), clang::SourceManager::getTopMacroCallerLoc(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::isa(), clang::DiagnosticsEngine::isIgnored(), clang::SourceLocation::isMacroID(), clang::Type::isNullPtrType(), clang::Sema::SourceMgr, and clang::T.
Referenced by clang::Sema::CheckImplicitConversion().
Detect if SizeofExpr is likely to calculate the sizeof an object.
Definition at line 10260 of file SemaChecking.cpp.
References doesExprLikelyComputeSize(), getAsSizeOfExpr(), and clang::Expr::IgnoreParenImpCasts().
Referenced by CheckMemaccessSize(), and doesExprLikelyComputeSize().
|
static |
Definition at line 9782 of file SemaChecking.cpp.
References clang::ASTContext::BuiltinInfo, clang::Sema::Context, clang::FixItHint::CreateReplacement(), clang::SemaBase::Diag(), clang::LookupResult::empty(), clang::IdentifierTable::get(), getAbsoluteValueKind(), clang::FunctionDecl::getBuiltinID(), clang::Sema::getCurScope(), clang::LookupResult::getFoundDecl(), 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(), clang::ASTContext::Idents, clang::LookupResult::isSingleResult(), clang::Sema::LookupAnyName, clang::Sema::LookupName(), clang::Sema::LookupQualifiedName(), and clang::LookupResult::suppressDiagnostics().
Referenced by clang::syntax::computeReplacements().
Definition at line 1629 of file SemaChecking.cpp.
References clang::Sema::Context, clang::APValue::LValueBase::dyn_cast(), clang::Expr::EvaluateAsRValue(), clang::APValue::getLValueBase(), and clang::Expr::EvalResult::Val.
Referenced by checkPointerAuthValue().
|
static |
Given a type tag expression find the type tag itself.
| TypeExpr | Type tag expression, as it appears in user's code. |
| VD | Declaration of an identifier that appears in a type tag. |
| MagicValue | Type tag magic value. |
| isConstantEvaluated | whether the evalaution should be performed in constant context. |
Definition at line 15853 of file SemaChecking.cpp.
References clang::cast(), clang::Expr::EvaluateAsBooleanCondition(), clang::AbstractConditionalOperator::getCond(), clang::DeclRefExpr::getDecl(), clang::AbstractConditionalOperator::getFalseExpr(), clang::BinaryOperator::getOpcode(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::AbstractConditionalOperator::getTrueExpr(), clang::APIntStorage::getValue(), clang::Expr::IgnoreParenCasts(), and clang::Expr::IgnoreParenImpCasts().
Referenced by GetMatchingCType().
|
static |
Definition at line 9625 of file SemaChecking.cpp.
References clang::Error, ASTContext::GE_None, clang::Type::getAs(), clang::FunctionProtoType::getNumParams(), and clang::FunctionProtoType::getParamType().
Referenced by getBestAbsFunction().
|
static |
Definition at line 9749 of file SemaChecking.cpp.
References clang::FunctionDecl::getBuiltinID(), and clang::NamedDecl::getIdentifier().
|
static |
Definition at line 9672 of file SemaChecking.cpp.
References AVK_Complex, AVK_Floating, AVK_Integer, and clang::T.
Referenced by emitReplacement().
|
static |
Compute the alignment and offset of a binary additive operator.
Definition at line 14833 of file SemaChecking.cpp.
References getBaseAlignmentAndOffsetFromPtr(), clang::Expr::getIntegerConstantExpr(), clang::Type::getPointeeType(), clang::Expr::getType(), clang::ASTContext::getTypeSizeInChars(), clang::Type::isConstantSizeType(), and clang::CharUnits::Zero().
Referenced by getBaseAlignmentAndOffsetFromLValue(), and getBaseAlignmentAndOffsetFromPtr().
|
static |
Definition at line 16495 of file SemaChecking.cpp.
References clang::Sema::Context, clang::SemaBase::Diag(), clang::Dim, clang::Stmt::getBeginLoc(), clang::Expr::getIntegerConstantExpr(), and clang::ASTContext::getLangOpts().
|
static |
Definition at line 10141 of file SemaChecking.cpp.
Referenced by doesExprLikelyComputeSize(), getSizeOfArgType(), and getSizeOfExprArg().
|
static |
This helper function takes an lvalue expression and returns the alignment of a VarDecl and a constant offset from the VarDecl.
Definition at line 14865 of file SemaChecking.cpp.
References clang::cast(), clang::CharUnits::fromQuantity(), getAlignmentAndOffsetFromBinAddOrSub(), clang::ASTContext::getASTRecordLayout(), clang::ArraySubscriptExpr::getBase(), getBaseAlignmentAndOffsetFromLValue(), getBaseAlignmentAndOffsetFromPtr(), clang::ASTContext::getDeclAlign(), getDerivedToBaseAlignmentAndOffset(), clang::ASTRecordLayout::getFieldOffset(), clang::ArraySubscriptExpr::getIdx(), clang::BinaryOperator::getOpcode(), clang::UnaryOperator::getOpcode(), clang::DeclContext::getParent(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::ValueDecl::getType(), clang::Expr::IgnoreParens(), clang::Type::isReferenceType(), and clang::CharUnits::Zero().
Referenced by getBaseAlignmentAndOffsetFromLValue(), and getBaseAlignmentAndOffsetFromPtr().
|
static |
This helper function takes a pointer expression and returns the alignment of a VarDecl and a constant offset from the VarDecl.
Definition at line 14958 of file SemaChecking.cpp.
References clang::cast(), getAlignmentAndOffsetFromBinAddOrSub(), clang::Type::getAsCXXRecordDecl(), clang::ASTContext::getASTRecordLayout(), getBaseAlignmentAndOffsetFromLValue(), getBaseAlignmentAndOffsetFromPtr(), getDerivedToBaseAlignmentAndOffset(), clang::BinaryOperator::getLHS(), clang::ASTRecordLayout::getNonVirtualAlignment(), clang::BinaryOperator::getOpcode(), clang::UnaryOperator::getOpcode(), clang::Type::getPointeeType(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::Expr::IgnoreParens(), and clang::CharUnits::Zero().
Referenced by getAlignmentAndOffsetFromBinAddOrSub(), getBaseAlignmentAndOffsetFromLValue(), getBaseAlignmentAndOffsetFromPtr(), and getPresumedAlignmentOfPointer().
|
static |
Definition at line 9647 of file SemaChecking.cpp.
References getAbsoluteValueArgumentType(), and getLargerAbsoluteValueFunction().
|
static |
Determine whether the given type is or contains a dynamic class type (e.g., whether it has a vtable).
Definition at line 10112 of file SemaChecking.cpp.
References clang::RecordDecl::fields(), clang::Type::getAsCXXRecordDecl(), getContainedDynamicClass(), clang::CXXRecordDecl::getDefinition(), clang::ValueDecl::getType(), clang::CXXRecordDecl::isDynamicClass(), clang::Decl::isInvalidDecl(), and clang::T.
Referenced by getContainedDynamicClass().
|
static |
Compute the alignment and offset of the base class object given the derived-to-base cast expression and the alignment and offset of the derived class object.
Definition at line 14804 of file SemaChecking.cpp.
References clang::Type::getAsCXXRecordDecl(), clang::ASTContext::getASTRecordLayout(), clang::ASTRecordLayout::getBaseClassOffset(), clang::ASTRecordLayout::getNonVirtualAlignment(), clang::CastExpr::path_begin(), clang::CastExpr::path_end(), and clang::CharUnits::Zero().
Referenced by getBaseAlignmentAndOffsetFromLValue(), and getBaseAlignmentAndOffsetFromPtr().
Definition at line 11195 of file SemaChecking.cpp.
References clang::Type::getAs(), and clang::Expr::getType().
Referenced by TryGetExprRange(), and TryGetExprRange().
|
static |
Definition at line 12526 of file SemaChecking.cpp.
Referenced by DiagnoseIntInBoolContext().
Definition at line 9575 of file SemaChecking.cpp.
Referenced by getBestAbsFunction().
|
static |
Retrieve the C type corresponding to type tag TypeExpr.
| TypeExpr | Expression that specifies a type tag. |
| MagicValues | Registered magic values. |
| FoundWrongKind | Set to true if a type tag was found, but of a wrong kind. |
| TypeInfo | Information about the corresponding C type. |
| isConstantEvaluated | whether the evalaution should be performed in constant context. |
Definition at line 15934 of file SemaChecking.cpp.
References FindTypeTagExpr(), and clang::Decl::getAttr().
Definition at line 15023 of file SemaChecking.cpp.
References clang::Sema::Context, getBaseAlignmentAndOffsetFromPtr(), clang::Type::getPointeeType(), clang::Expr::getType(), and clang::ASTContext::getTypeAlignInChars().
Referenced by clang::Sema::CheckCastAlign().
If E is a sizeof expression, returns its argument type.
Definition at line 10158 of file SemaChecking.cpp.
References getAsSizeOfExpr(), and SizeOf.
If E is a sizeof expression, returns its argument expression, otherwise returns NULL.
Definition at line 10150 of file SemaChecking.cpp.
References getAsSizeOfExpr(), and SizeOf.
Definition at line 10669 of file SemaChecking.cpp.
References clang::CallExpr::getArg(), clang::CallExpr::getDirectCallee(), clang::FunctionDecl::getMemoryFunctionKind(), and clang::Expr::IgnoreParenCasts().
Definition at line 11167 of file SemaChecking.cpp.
References clang::APValue::getComplexIntImag(), clang::APValue::getComplexIntReal(), clang::APValue::getInt(), GetValueRange(), clang::APValue::getVectorElt(), clang::APValue::getVectorLength(), clang::APValue::isAddrLabelDiff(), clang::APValue::isComplexInt(), clang::APValue::isInt(), clang::APValue::isLValue(), clang::Type::isUnsignedIntegerOrEnumerationType(), and clang::APValue::isVector().
|
static |
Definition at line 11155 of file SemaChecking.cpp.
Referenced by GetValueRange(), and TryGetExprRange().
|
static |
Definition at line 1860 of file SemaChecking.cpp.
References clang::Call, clang::Type::canDecayToPointerType(), clang::Sema::checkArgCount(), clang::Sema::Context, clang::Sema::DefaultFunctionArrayLvalueConversion(), clang::SemaBase::Diag(), clang::ExprError(), clang::ActionResult< PtrTy, Compress >::get(), clang::Stmt::getBeginLoc(), clang::ASTContext::getDecayedType(), clang::Type::getPointeeCXXRecordDecl(), clang::Type::getPointeeType(), clang::ASTContext::getPointerType(), clang::Expr::getType(), clang::Type::isArrayType(), clang::ActionResult< PtrTy, Compress >::isInvalid(), clang::CXXRecordDecl::isPolymorphic(), clang::Sema::RequireCompleteType(), clang::ASTContext::VoidTy, and clang::CanQual< T >::withConst().
|
static |
Definition at line 8744 of file SemaChecking.cpp.
References clang::DiagnosticsEngine::isIgnored(), clang::analyze_format_string::ArgType::Match, clang::Match, and clang::analyze_format_string::ArgType::NoMatchSignedness.
Definition at line 11729 of file SemaChecking.cpp.
References clang::Expr::getType(), and clang::Type::isEnumeralType().
Referenced by CheckTautologicalComparison().
|
static |
Definition at line 10559 of file SemaChecking.cpp.
References clang::BinaryOperator::getLHS(), clang::BinaryOperator::getRHS(), clang::Expr::IgnoreParenCasts(), clang::isa(), and clang::BinaryOperator::isAdditiveOp().
|
static |
Check if the ArgLoc originated from a macro passed to the call at CallLoc.
This should return true for the first call to foo, but not for the second (regardless of whether foo is a macro or function).
Definition at line 10284 of file SemaChecking.cpp.
References clang::SourceLocation::isMacroID(), and SM.
Referenced by CheckMemaccessSize().
|
static |
Return true if ICE is an implicit argument promotion of an arithmetic type.
Bit-field 'promotions' from a higher ranked type to a lower ranked type do not count.
Definition at line 8723 of file SemaChecking.cpp.
References clang::Sema::Context, clang::Type::getAs(), clang::CastExpr::getCastKind(), clang::ASTContext::getFloatingTypeOrder(), clang::ASTContext::getPromotedIntegerType(), clang::CastExpr::getSubExpr(), clang::Expr::getType(), and clang::ASTContext::isPromotableIntegerType().
|
static |
Definition at line 10581 of file SemaChecking.cpp.
References clang::Type::isVariableArrayType().
Definition at line 11578 of file SemaChecking.cpp.
References clang::Stmt::getBeginLoc(), clang::Lexer::getImmediateMacroName(), clang::Sema::getLangOpts(), clang::Sema::getSourceManager(), clang::Expr::IgnoreParenImpCasts(), clang::isa(), and clang::SourceLocation::isMacroID().
Referenced by CheckTautologicalComparison().
Definition at line 12412 of file SemaChecking.cpp.
References clang::Sema::Context, clang::ASTContext::getCanonicalType(), clang::Expr::getType(), clang::CanQual< T >::getTypePtr(), clang::Expr::IgnoreParenImpCasts(), clang::isa(), and clang::Type::isSpecificBuiltinType().
Referenced by CheckImplicitArgumentConversions().
|
static |
Definition at line 13506 of file SemaChecking.cpp.
References clang::SourceLocation::isInvalid(), clang::SourceLocation::isMacroID(), and SM.
Referenced by clang::Sema::DiagnoseAlwaysNonNullPointer().
|
static |
Definition at line 9894 of file SemaChecking.cpp.
References clang::Decl::getDeclContext(), clang::NamedDecl::getName(), clang::DeclContext::getParent(), and clang::DeclContext::isStdNamespace().
Definition at line 9878 of file SemaChecking.cpp.
|
static |
Definition at line 7993 of file SemaChecking.cpp.
References clang::OSLog, and clang::T.
Definition at line 11598 of file SemaChecking.cpp.
References clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), clang::Type::isIntegerType(), and clang::Type::isSignedIntegerType().
Referenced by CheckTautologicalComparison().
|
static |
Check if two enumeration types are layout-compatible.
Definition at line 15672 of file SemaChecking.cpp.
References clang::C, clang::EnumDecl::getIntegerType(), and clang::EnumDecl::isComplete().
|
static |
Check if two fields are layout-compatible.
Can be used on union members, which are exempt from alignment requirement of common initial sequence.
Definition at line 15684 of file SemaChecking.cpp.
References clang::C, clang::FieldDecl::getBitWidthValue(), clang::Decl::getMaxAlignment(), clang::FieldDecl::getParent(), clang::ValueDecl::getType(), clang::Decl::hasAttr(), clang::FieldDecl::isBitField(), and isLayoutCompatible().
|
static |
Definition at line 15770 of file SemaChecking.cpp.
References clang::C, isLayoutCompatibleStruct(), isLayoutCompatibleUnion(), and clang::TagDecl::isUnion().
|
static |
Check if two types are layout-compatible in C++11 sense.
Definition at line 15782 of file SemaChecking.cpp.
References clang::C, clang::Type::castAsEnumDecl(), clang::Type::castAsRecordDecl(), clang::QualType::getCanonicalType(), clang::Type::getTypeClass(), clang::QualType::getUnqualifiedType(), isLayoutCompatible(), clang::QualType::isNull(), and clang::Type::isStandardLayoutType().
Referenced by clang::Sema::IsLayoutCompatible(), isLayoutCompatible(), isLayoutCompatible(), and isLayoutCompatibleUnion().
|
static |
Check if two standard-layout structs are layout-compatible.
(C++11 [class.mem] p17)
Definition at line 15728 of file SemaChecking.cpp.
References clang::C, and clang::RecordDecl::fields().
Referenced by isLayoutCompatible().
|
static |
Check if two standard-layout unions are layout-compatible.
(C++11 [class.mem] p18)
Definition at line 15746 of file SemaChecking.cpp.
References clang::C, clang::RecordDecl::fields(), and isLayoutCompatible().
Referenced by isLayoutCompatible().
Determine whether the given type has a non-null nullability annotation.
Definition at line 3724 of file SemaChecking.cpp.
References clang::NonNull, and clang::ast_matchers::type.
Referenced by CheckNonNullArguments().
Definition at line 15991 of file SemaChecking.cpp.
References clang::Type::getAs(), and clang::BuiltinType::getKind().
|
static |
Checks whether the given value, which currently has the given source semantics, has the same value when coerced through the target semantics.
The value might be a vector of floats (or a complex number).
Definition at line 11557 of file SemaChecking.cpp.
References clang::APValue::getComplexFloatImag(), clang::APValue::getComplexFloatReal(), clang::APValue::getFloat(), clang::APValue::getVectorElt(), clang::APValue::getVectorLength(), clang::APValue::isComplexFloat(), clang::APValue::isFloat(), IsSameFloatAfterCast(), and clang::APValue::isVector().
|
static |
Checks whether the given value, which currently has the given source semantics, has the same value when coerced through the target semantics.
Definition at line 11540 of file SemaChecking.cpp.
Referenced by clang::Sema::CheckImplicitConversion(), and IsSameFloatAfterCast().
|
static |
Definition at line 12502 of file SemaChecking.cpp.
References clang::SourceManager::getCharacterData(), clang::Sema::getSourceManager(), clang::Expr::IgnoreParenImpCasts(), clang::SourceLocation::isValid(), and clang::T.
Referenced by clang::Sema::CheckImplicitConversion().
|
static |
Definition at line 6260 of file SemaChecking.cpp.
Referenced by clang::Sema::BuiltinConstantArgShiftedByte(), and clang::Sema::BuiltinConstantArgShiftedByteOrXXFF().
|
static |
Definition at line 9865 of file SemaChecking.cpp.
References clang::NamedDecl::getIdentifier(), clang::Decl::isInStdNamespace(), and clang::IdentifierInfo::isStr().
Definition at line 2134 of file SemaChecking.cpp.
References clang::T.
Referenced by checkMathBuiltinElementType().
|
static |
Definition at line 4269 of file SemaChecking.cpp.
Referenced by clang::Sema::BuildAtomicExpr().
|
static |
Definition at line 7026 of file SemaChecking.cpp.
References clang::Expr::EvaluateAsRValue().
Referenced by checkFormatStringExpr().
|
static |
Definition at line 1826 of file SemaChecking.cpp.
References clang::Call, clang::Sema::checkArgCount(), checkPointerAuthEnabled(), checkPointerAuthKey(), checkPointerAuthValue(), and clang::ExprError().
|
static |
Definition at line 1783 of file SemaChecking.cpp.
References clang::Call, clang::Sema::checkArgCount(), checkPointerAuthEnabled(), checkPointerAuthValue(), clang::Sema::Context, clang::ExprError(), and clang::ASTContext::getUIntPtrType().
|
static |
Definition at line 1796 of file SemaChecking.cpp.
References clang::Call, clang::Sema::checkArgCount(), checkPointerAuthEnabled(), checkPointerAuthValue(), clang::Sema::Context, clang::ExprError(), and clang::ASTContext::getUIntPtrType().
|
static |
Definition at line 1809 of file SemaChecking.cpp.
References clang::Call, clang::Sema::checkArgCount(), checkPointerAuthEnabled(), checkPointerAuthKey(), checkPointerAuthValue(), and clang::ExprError().
|
static |
Definition at line 1842 of file SemaChecking.cpp.
References clang::Call, checkPointerAuthEnabled(), clang::SemaBase::Diag(), clang::ExprError(), clang::Expr::getExprLoc(), and clang::Stmt::getSourceRange().
|
static |
Definition at line 1770 of file SemaChecking.cpp.
References clang::Call, clang::Sema::checkArgCount(), checkPointerAuthEnabled(), checkPointerAuthKey(), checkPointerAuthValue(), and clang::ExprError().
|
static |
Definition at line 12402 of file SemaChecking.cpp.
References toString().
Referenced by clang::Sema::CheckImplicitConversion().
|
static |
Definition at line 1126 of file SemaChecking.cpp.
References clang::T.
Check if two expressions refer to the same declaration.
Definition at line 10662 of file SemaChecking.cpp.
Definition at line 8627 of file SemaChecking.cpp.
References clang::Stmt::getStmtClass(), and clang::Expr::IgnoreImpCasts().
|
static |
Definition at line 15458 of file SemaChecking.cpp.
References clang::NullStmt::getSemiLoc(), and clang::NullStmt::hasLeadingEmptyMacro().
Referenced by clang::Sema::DiagnoseEmptyLoopBody(), and clang::Sema::DiagnoseEmptyStmtBody().
|
static |
Definition at line 8664 of file SemaChecking.cpp.
References clang::Type::getAs(), clang::QualType::isNull(), and shouldNotPrintDirectly().
Referenced by shouldNotPrintDirectly().
|
static |
Definition at line 6507 of file SemaChecking.cpp.
References sumOffsets().
Referenced by checkFormatStringExpr(), and sumOffsets().
|
static |
Definition at line 11530 of file SemaChecking.cpp.
References clang::C, GetExprType(), and TryGetExprRange().
|
static |
Attempts to estimate an approximate range for the given integer expression.
Returns a range if successful, otherwise it returns std::nullopt if a reliable estimation cannot be determined.
| MaxWidth | The width to which the value will be truncated. |
| InConstantContext | If true, interpret the expression within a constant context. |
| Approximate | If true, provide a likely range of values by assuming that arithmetic on narrower types remains within those types. If false, return a range that includes all possible values resulting from the expression. |
Definition at line 11215 of file SemaChecking.cpp.
References clang::C, clang::Expr::EvaluateAsRValue(), GetExprType(), clang::Expr::getSourceBitField(), clang::Expr::getType(), GetValueRange(), clang::Expr::IgnoreParens(), clang::Type::isUnsignedIntegerType(), clang::Type::isVoidType(), log2, clang::T, TryGetExprRange(), and clang::Expr::EvalResult::Val.
Referenced by AnalyzeComparison(), clang::Sema::CheckImplicitConversion(), CheckTautologicalComparison(), TryGetExprRange(), and TryGetExprRange().