clang 20.0.0git
Macros | Enumerations | Functions
SemaChecking.cpp File Reference
#include "clang/AST/APValue.h"
#include "clang/AST/ASTContext.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/ExprOpenMP.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/Type.h"
#include "clang/AST/TypeLoc.h"
#include "clang/AST/UnresolvedSet.h"
#include "clang/Basic/AddressSpaces.h"
#include "clang/Basic/CharInfo.h"
#include "clang/Basic/Diagnostic.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/TargetBuiltins.h"
#include "clang/Basic/TargetCXXABI.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/SemaHLSL.h"
#include "clang/Sema/SemaHexagon.h"
#include "clang/Sema/SemaInternal.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/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/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/Casting.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 <bitset>
#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 BUILTIN(ID, TYPE, ATTRS)
 
#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 checkPointerAuthEnabled (Sema &S, Expr *E)
 
static bool checkPointerAuthKey (Sema &S, Expr *&Arg)
 
static std::pair< const ValueDecl *, CharUnitsfindConstantBaseAndOffset (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 BuiltinLaunder (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 checkMathBuiltinElementType (Sema &S, SourceLocation Loc, QualType ArgTy, int ArgIndex)
 
static bool checkFPMathBuiltinElementType (Sema &S, SourceLocation Loc, QualType ArgTy, int ArgIndex)
 
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 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 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 Expr *OrigFormatExpr, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, bool inFunctionCall, Sema::VariadicCallType CallType, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, bool IgnoreStringsWithoutSpecifiers)
 
static const ExprmaybeConstEvalStringLiteral (ASTContext &Context, const Expr *E)
 
static StringLiteralCheckType checkFormatStringExpr (Sema &S, const Expr *E, ArrayRef< const Expr * > Args, Sema::FormatArgumentPassingKind APK, unsigned format_idx, unsigned firstDataArg, Sema::FormatStringType Type, Sema::VariadicCallType CallType, bool InFunctionCall, llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg, llvm::APSInt Offset, bool IgnoreStringsWithoutSpecifiers=false)
 
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 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 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.
 
static const CXXRecordDeclgetContainedDynamicClass (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 UnaryExprOrTypeTraitExprgetAsSizeOfExpr (const Expr *E)
 
static const ExprgetSizeOfExprArg (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 ExprignoreLiteralAdditions (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 ExprgetStrlenExprArg (const Expr *E)
 
static IntRange GetValueRange (ASTContext &C, llvm::APSInt &value, unsigned MaxWidth)
 
static IntRange GetValueRange (ASTContext &C, APValue &result, QualType Ty, unsigned MaxWidth)
 
static QualType GetExprType (const Expr *E)
 
static IntRange GetExprRange (ASTContext &C, const Expr *E, unsigned MaxWidth, bool InConstantContext, bool Approximate)
 Pseudo-evaluate the given integer expression, estimating the range of values it might take.
 
static IntRange GetExprRange (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, Expr *E)
 
static bool isKnownToHaveUnsignedValue (Expr *E)
 
static bool HasEnumType (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, 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, 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, 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, Expr *Ex, bool ToBool)
 
static void CheckImplicitArgumentConversions (Sema &S, 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 IntegerLiteralgetIntegerLiteral (Expr *E)
 
static void DiagnoseIntInBoolContext (Sema &S, Expr *E)
 
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 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, CharUnitsgetDerivedToBaseAlignmentAndOffset (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 std::optional< unsignedgetAndVerifyMatrixDimension (Expr *Expr, StringRef Name, Sema &S)
 

Macro Definition Documentation

◆ ATOMIC_BUILTIN

#define ATOMIC_BUILTIN (   ID,
  TYPE,
  ATTRS 
)
Value:
case Builtin::BI##ID: \
return AtomicOpsOverloaded(TheCallResult, AtomicExpr::AO##ID);

◆ BUILTIN

#define BUILTIN (   ID,
  TYPE,
  ATTRS 
)

◆ BUILTIN_ROW

#define BUILTIN_ROW (   x)
Value:
{ Builtin::BI##x##_1, Builtin::BI##x##_2, Builtin::BI##x##_4, \
Builtin::BI##x##_8, Builtin::BI##x##_16 }
__inline void unsigned int _2
Definition: larchintrin.h:181

Enumeration Type Documentation

◆ AbsoluteValueKind

Enumerator
AVK_Integer 
AVK_Floating 
AVK_Complex 

Definition at line 8010 of file SemaChecking.cpp.

◆ MathCheck

enum class MathCheck
strong
Enumerator
NaN 
Inf 

Definition at line 8221 of file SemaChecking.cpp.

Function Documentation

◆ AnalyzeAssignment()

static void AnalyzeAssignment ( Sema S,
BinaryOperator E 
)
static

◆ AnalyzeBitFieldAssignment()

static bool AnalyzeBitFieldAssignment ( Sema S,
FieldDecl Bitfield,
Expr Init,
SourceLocation  InitLoc 
)
static

◆ AnalyzeComparison()

static void AnalyzeComparison ( Sema S,
BinaryOperator E 
)
static

◆ AnalyzeCompoundAssignment()

static void AnalyzeCompoundAssignment ( Sema S,
BinaryOperator E 
)
static

◆ AnalyzeImpConvsInComparison()

static void AnalyzeImpConvsInComparison ( Sema S,
BinaryOperator E 
)
static

Analyze the operands of the given comparison.

Implements the fallback case from AnalyzeComparison.

Definition at line 10143 of file SemaChecking.cpp.

References AnalyzeImplicitConversions(), and E.

Referenced by AnalyzeComparison().

◆ AnalyzeImplicitConversions() [1/2]

static void AnalyzeImplicitConversions ( Sema S,
AnalyzeImplicitConversionsWorkItem  Item,
llvm::SmallVectorImpl< AnalyzeImplicitConversionsWorkItem > &  WorkList 
)
static

◆ AnalyzeImplicitConversions() [2/2]

static void AnalyzeImplicitConversions ( Sema S,
Expr OrigE,
SourceLocation  CC,
bool  IsListInit 
)
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 11500 of file SemaChecking.cpp.

References AnalyzeImplicitConversions().

Referenced by AnalyzeAssignment(), AnalyzeComparison(), AnalyzeCompoundAssignment(), AnalyzeImpConvsInComparison(), AnalyzeImplicitConversions(), CheckConditionalOperand(), and CheckConditionalOperator().

◆ BuiltinAddressof()

static bool BuiltinAddressof ( Sema S,
CallExpr TheCall 
)
static

Check that the argument to __builtin_addressof is a glvalue, and set the result type to the corresponding pointer type.

Definition at line 270 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().

◆ BuiltinAlignment()

static bool BuiltinAlignment ( Sema S,
CallExpr TheCall,
unsigned  ID 
)
static

◆ builtinAllocaAddrSpace()

static void builtinAllocaAddrSpace ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinAnnotation()

static bool BuiltinAnnotation ( Sema S,
CallExpr TheCall 
)
static

Check that the first argument to __builtin_annotation is an integer and the second argument is a non-wide string literal.

Definition at line 220 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().

◆ BuiltinCallWithStaticChain()

static bool BuiltinCallWithStaticChain ( Sema S,
CallExpr BuiltinCall 
)
static

◆ BuiltinCountZeroBitsGeneric()

static bool BuiltinCountZeroBitsGeneric ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinCpu()

static bool BuiltinCpu ( Sema S,
const TargetInfo TI,
CallExpr TheCall,
const TargetInfo AuxTI,
unsigned  BuiltinID 
)
static

◆ BuiltinDumpStruct()

static ExprResult BuiltinDumpStruct ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinFunctionStart()

static bool BuiltinFunctionStart ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinLaunder()

static ExprResult BuiltinLaunder ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinMSVCAnnotation()

static bool BuiltinMSVCAnnotation ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinOverflow()

static bool BuiltinOverflow ( Sema S,
CallExpr TheCall,
unsigned  BuiltinID 
)
static

◆ BuiltinPopcountg()

static bool BuiltinPopcountg ( Sema S,
CallExpr TheCall 
)
static

◆ BuiltinPreserveAI()

static bool BuiltinPreserveAI ( Sema S,
CallExpr TheCall 
)
static

Check the number of arguments and set the result type to the argument type.

Definition at line 309 of file SemaChecking.cpp.

References clang::Sema::checkArgCount(), clang::CallExpr::getArg(), clang::Expr::getType(), and clang::Expr::setType().

◆ BuiltinSEHScopeCheck()

static bool BuiltinSEHScopeCheck ( Sema SemaRef,
CallExpr TheCall,
Scope::ScopeFlags  NeededScopeFlags,
unsigned  DiagID 
)
static

◆ changeAbsFunction()

static unsigned changeAbsFunction ( unsigned  AbsKind,
AbsoluteValueKind  ValueKind 
)
static

Definition at line 8029 of file SemaChecking.cpp.

References AVK_Complex, AVK_Floating, and AVK_Integer.

◆ CheckBoolLikeConversion()

static void CheckBoolLikeConversion ( Sema S,
Expr E,
SourceLocation  CC 
)
static

Check conversion of given expression to boolean.

Input argument E is a logical expression.

Definition at line 11310 of file SemaChecking.cpp.

References clang::ASTContext::BoolTy, clang::Sema::CheckImplicitConversion(), clang::Sema::Context, E, clang::Sema::getLangOpts(), clang::Expr::getType(), clang::Expr::IgnoreParenImpCasts(), and clang::Type::isAtomicType().

Referenced by AnalyzeImplicitConversions().

◆ checkBuiltinArgument()

static bool checkBuiltinArgument ( Sema S,
CallExpr E,
unsigned  ArgIndex 
)
static

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 4122 of file SemaChecking.cpp.

References clang::Sema::Context, E, clang::ActionResult< PtrTy, Compress >::get(), clang::InitializedEntity::InitializeParameter(), clang::ActionResult< PtrTy, Compress >::isInvalid(), and clang::Sema::PerformCopyInitialization().

◆ CheckBuiltinTargetInSupported()

static bool CheckBuiltinTargetInSupported ( Sema S,
CallExpr TheCall,
ArrayRef< llvm::Triple::ArchType >  SupportedArchs 
)
static

◆ CheckBuiltinTargetNotInUnsupported()

static bool CheckBuiltinTargetNotInUnsupported ( Sema S,
unsigned  BuiltinID,
CallExpr TheCall,
ArrayRef< llvm::Triple::ObjectFormatType >  UnsupportedObjectFormatTypes 
)
static

◆ checkBuiltinVerboseTrap()

static bool checkBuiltinVerboseTrap ( CallExpr Call,
Sema S 
)
static

◆ CheckConditionalOperand()

static void CheckConditionalOperand ( Sema S,
Expr E,
QualType  T,
SourceLocation  CC,
bool ICContext 
)
static

◆ CheckConditionalOperator()

static void CheckConditionalOperator ( Sema S,
AbstractConditionalOperator E,
SourceLocation  CC,
QualType  T 
)
static

◆ CheckFormatString()

static void CheckFormatString ( Sema S,
const FormatStringLiteral *  FExpr,
const Expr OrigFormatExpr,
ArrayRef< const Expr * >  Args,
Sema::FormatArgumentPassingKind  APK,
unsigned  format_idx,
unsigned  firstDataArg,
Sema::FormatStringType  Type,
bool  inFunctionCall,
Sema::VariadicCallType  CallType,
llvm::SmallBitVector &  CheckedVarArgs,
UncoveredArgHandler &  UncoveredArg,
bool  IgnoreStringsWithoutSpecifiers 
)
static

◆ checkFormatStringExpr()

static StringLiteralCheckType checkFormatStringExpr ( Sema S,
const Expr E,
ArrayRef< const Expr * >  Args,
Sema::FormatArgumentPassingKind  APK,
unsigned  format_idx,
unsigned  firstDataArg,
Sema::FormatStringType  Type,
Sema::VariadicCallType  CallType,
bool  InFunctionCall,
llvm::SmallBitVector &  CheckedVarArgs,
UncoveredArgHandler &  UncoveredArg,
llvm::APSInt  Offset,
bool  IgnoreStringsWithoutSpecifiers = false 
)
static

Definition at line 5671 of file SemaChecking.cpp.

References clang::Sema::FormatStringInfo::ArgPassingKind, clang::C, CheckFormatString(), checkFormatStringExpr(), combineFAPK(), clang::Sema::Context, D, E, clang::Expr::EvaluateAsInt(), clang::Sema::FAPK_Fixed, clang::Sema::FAPK_VAList, clang::Sema::FAPK_Variadic, clang::Sema::FormatStringInfo::FormatIdx, clang::CallExpr::getArg(), clang::Type::getAs(), clang::ASTContext::getAsArrayType(), clang::Sema::getASTContext(), clang::FunctionDecl::getBuiltinID(), clang::CallExpr::getCalleeDecl(), clang::DeclRefExpr::getDecl(), clang::Sema::getFormatStringInfo(), clang::Sema::GetFormatStringType(), clang::Decl::getFunctionType(), clang::NamedDecl::getIdentifier(), clang::APValue::getInt(), clang::StringLiteral::getLength(), clang::BinaryOperator::getLHS(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::Type::getPointeeType(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::StringLiteral::getString(), clang::UnaryOperator::getSubExpr(), clang::Expr::getType(), clang::Expr::IgnoreParenCasts(), clang::Init, clang::BinaryOperator::isAdditiveOp(), clang::QualType::isConstant(), clang::Sema::isConstantEvaluatedContext(), clang::Expr::isNullPointerConstant(), clang::Type::isObjCObjectPointerType(), clang::IdentifierInfo::isStr(), clang::Expr::isTypeDependent(), clang::Expr::isValueDependent(), maybeConstEvalStringLiteral(), clang::Expr::NPC_ValueDependentIsNotNull, clang::Result, clang::Expr::SE_NoSideEffects, clang::Decl::specific_attrs(), sumOffsets(), clang::T, and clang::Expr::EvalResult::Val.

Referenced by checkFormatStringExpr().

◆ CheckForReference()

static bool CheckForReference ( Sema SemaRef,
const Expr E,
const PartialDiagnostic PD 
)
static

◆ checkFPMathBuiltinElementType()

static bool checkFPMathBuiltinElementType ( Sema S,
SourceLocation  Loc,
QualType  ArgTy,
int  ArgIndex 
)
static

◆ CheckImplicitArgumentConversions()

static void CheckImplicitArgumentConversions ( Sema S,
CallExpr TheCall,
SourceLocation  CC 
)
static

◆ checkMathBuiltinElementType()

static bool checkMathBuiltinElementType ( Sema S,
SourceLocation  Loc,
QualType  ArgTy,
int  ArgIndex 
)
static

◆ CheckMemaccessSize()

static void CheckMemaccessSize ( Sema S,
unsigned  BId,
const CallExpr Call 
)
static

◆ CheckMemorySizeofForComparison()

static bool CheckMemorySizeofForComparison ( Sema S,
const Expr E,
IdentifierInfo FnName,
SourceLocation  FnLoc,
SourceLocation  RParenLoc 
)
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 8411 of file SemaChecking.cpp.

References clang::FixItHint::CreateInsertion(), clang::FixItHint::CreateRemoval(), clang::SemaBase::Diag(), E, clang::SourceRange::getBegin(), clang::SourceRange::getEnd(), and clang::Sema::getLocForEndOfToken().

◆ CheckNonNullArgument()

static void CheckNonNullArgument ( Sema S,
const Expr ArgExpr,
SourceLocation  CallSiteLoc 
)
static

◆ CheckNonNullArguments()

static void CheckNonNullArguments ( Sema S,
const NamedDecl FDecl,
const FunctionProtoType Proto,
ArrayRef< const Expr * >  Args,
SourceLocation  CallSiteLoc 
)
static

◆ CheckNonNullExpr()

static bool CheckNonNullExpr ( Sema S,
const Expr Expr 
)
static

◆ checkPointerAuthEnabled()

static bool checkPointerAuthEnabled ( Sema S,
Expr E 
)
static

◆ checkPointerAuthKey()

static bool checkPointerAuthKey ( Sema S,
Expr *&  Arg 
)
static

◆ checkPointerAuthValue()

static bool checkPointerAuthValue ( Sema S,
Expr *&  Arg,
PointerAuthOpKind  OpKind,
bool  RequireConstant = false 
)
static

◆ CheckTautologicalComparison()

static bool CheckTautologicalComparison ( Sema S,
BinaryOperator E,
Expr Constant,
Expr Other,
const llvm::APSInt Value,
bool  RhsConstant 
)
static

◆ checkUnsafeAssignLiteral()

static bool checkUnsafeAssignLiteral ( Sema S,
SourceLocation  Loc,
Expr RHS,
bool  isProperty 
)
static

◆ checkUnsafeAssignObject()

static bool checkUnsafeAssignObject ( Sema S,
SourceLocation  Loc,
Qualifiers::ObjCLifetime  LT,
Expr RHS,
bool  isProperty 
)
static

◆ checkVAStartABI()

static bool checkVAStartABI ( Sema S,
unsigned  BuiltinID,
Expr Fn 
)
static

◆ checkVAStartIsInVariadicFunction()

static bool checkVAStartIsInVariadicFunction ( Sema S,
Expr Fn,
ParmVarDecl **  LastParam = nullptr 
)
static

◆ classifyConstantValue()

static int classifyConstantValue ( Expr Constant)
static

Definition at line 9975 of file SemaChecking.cpp.

Referenced by CheckTautologicalComparison().

◆ combineFAPK()

static constexpr unsigned short combineFAPK ( Sema::FormatArgumentPassingKind  A,
Sema::FormatArgumentPassingKind  B 
)
staticconstexpr

Definition at line 129 of file SemaChecking.cpp.

Referenced by checkFormatStringExpr().

◆ convertArgumentToType()

static bool convertArgumentToType ( Sema S,
Expr *&  Value,
QualType  Ty 
)
static

◆ CXXRecordMembersNamed()

template<typename MemberKind >
static llvm::SmallPtrSet< MemberKind *, 1 > CXXRecordMembersNamed ( StringRef  Name,
Sema S,
QualType  Ty 
)
static

◆ diagnoseArrayStarInParamType()

static void diagnoseArrayStarInParamType ( Sema S,
QualType  PType,
SourceLocation  Loc 
)
static

◆ DiagnoseFloatingImpCast()

static void DiagnoseFloatingImpCast ( Sema S,
Expr E,
QualType  T,
SourceLocation  CContext 
)
static

◆ DiagnoseImpCast() [1/2]

static void DiagnoseImpCast ( Sema S,
Expr E,
QualType  SourceType,
QualType  T,
SourceLocation  CContext,
unsigned  diag,
bool  pruneControlFlow = false 
)
static

◆ DiagnoseImpCast() [2/2]

static void DiagnoseImpCast ( Sema S,
Expr E,
QualType  T,
SourceLocation  CContext,
unsigned  diag,
bool  pruneControlFlow = false 
)
static

Diagnose an implicit cast; purely a helper for CheckImplicitConversion.

Definition at line 10445 of file SemaChecking.cpp.

References DiagnoseImpCast(), E, clang::Expr::getType(), and clang::T.

◆ DiagnoseIntInBoolContext()

static void DiagnoseIntInBoolContext ( Sema S,
Expr E 
)
static

◆ DiagnoseNullConversion()

static void DiagnoseNullConversion ( Sema S,
Expr E,
QualType  T,
SourceLocation  CC 
)
static

◆ doesExprLikelyComputeSize()

static bool doesExprLikelyComputeSize ( const Expr SizeofExpr)
static

Detect if SizeofExpr is likely to calculate the sizeof an object.

Definition at line 8586 of file SemaChecking.cpp.

References doesExprLikelyComputeSize(), getAsSizeOfExpr(), and clang::Expr::IgnoreParenImpCasts().

Referenced by CheckMemaccessSize(), and doesExprLikelyComputeSize().

◆ emitReplacement()

static void emitReplacement ( Sema S,
SourceLocation  Loc,
SourceRange  Range,
unsigned  AbsKind,
QualType  ArgType 
)
static

◆ findConstantBaseAndOffset()

static std::pair< const ValueDecl *, CharUnits > findConstantBaseAndOffset ( Sema S,
Expr E 
)
static

◆ FindTypeTagExpr()

static bool FindTypeTagExpr ( const Expr TypeExpr,
const ASTContext Ctx,
const ValueDecl **  VD,
uint64_t *  MagicValue,
bool  isConstantEvaluated 
)
static

Given a type tag expression find the type tag itself.

Parameters
TypeExprType tag expression, as it appears in user's code.
VDDeclaration of an identifier that appears in a type tag.
MagicValueType tag magic value.
isConstantEvaluatedwhether the evalaution should be performed in constant context.

Definition at line 13897 of file SemaChecking.cpp.

References clang::Expr::EvaluateAsBooleanCondition(), clang::AbstractConditionalOperator::getCond(), clang::DeclRefExpr::getDecl(), clang::AbstractConditionalOperator::getFalseExpr(), clang::UnaryOperator::getOpcode(), clang::BinaryOperator::getOpcode(), clang::BinaryOperator::getRHS(), clang::Stmt::getStmtClass(), clang::UnaryOperator::getSubExpr(), clang::AbstractConditionalOperator::getTrueExpr(), clang::APIntStorage::getValue(), clang::Expr::IgnoreParenCasts(), clang::Expr::IgnoreParenImpCasts(), and clang::Result.

Referenced by GetMatchingCType().

◆ getAbsoluteValueArgumentType()

static QualType getAbsoluteValueArgumentType ( ASTContext Context,
unsigned  AbsType 
)
static

◆ getAbsoluteValueFunctionKind()

static unsigned getAbsoluteValueFunctionKind ( const FunctionDecl FDecl)
static

◆ getAbsoluteValueKind()

static AbsoluteValueKind getAbsoluteValueKind ( QualType  T)
static

◆ getAlignmentAndOffsetFromBinAddOrSub()

static std::optional< std::pair< CharUnits, CharUnits > > getAlignmentAndOffsetFromBinAddOrSub ( const Expr PtrE,
const Expr IntE,
bool  IsSub,
ASTContext Ctx 
)
static

◆ getAndVerifyMatrixDimension()

static std::optional< unsigned > getAndVerifyMatrixDimension ( Expr Expr,
StringRef  Name,
Sema S 
)
static

◆ getAsSizeOfExpr()

static const UnaryExprOrTypeTraitExpr * getAsSizeOfExpr ( const Expr E)
static

Definition at line 8470 of file SemaChecking.cpp.

References E.

Referenced by doesExprLikelyComputeSize(), getSizeOfArgType(), and getSizeOfExprArg().

◆ getBaseAlignmentAndOffsetFromLValue()

static std::optional< std::pair< CharUnits, CharUnits > > getBaseAlignmentAndOffsetFromLValue ( const Expr E,
ASTContext Ctx 
)
static

◆ getBaseAlignmentAndOffsetFromPtr()

static std::optional< std::pair< CharUnits, CharUnits > > getBaseAlignmentAndOffsetFromPtr ( const Expr E,
ASTContext Ctx 
)
static

◆ getBestAbsFunction()

static unsigned getBestAbsFunction ( ASTContext Context,
QualType  ArgType,
unsigned  AbsFunctionKind 
)
static

◆ getContainedDynamicClass()

static const CXXRecordDecl * getContainedDynamicClass ( QualType  T,
bool IsContained 
)
static

◆ getDerivedToBaseAlignmentAndOffset()

static std::pair< CharUnits, CharUnits > getDerivedToBaseAlignmentAndOffset ( const CastExpr CE,
QualType  DerivedType,
CharUnits  BaseAlignment,
CharUnits  Offset,
ASTContext Ctx 
)
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 12841 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().

◆ GetExprRange() [1/2]

static IntRange GetExprRange ( ASTContext C,
const Expr E,
bool  InConstantContext,
bool  Approximate 
)
static

Definition at line 9764 of file SemaChecking.cpp.

References clang::C, E, GetExprRange(), and GetExprType().

◆ GetExprRange() [2/2]

static IntRange GetExprRange ( ASTContext C,
const Expr E,
unsigned  MaxWidth,
bool  InConstantContext,
bool  Approximate 
)
static

Pseudo-evaluate the given integer expression, estimating the range of values it might take.

Parameters
MaxWidthThe width to which the value will be truncated.
ApproximateIf true, return a likely range for the result: in particular, assume that arithmetic on narrower types doesn't leave those types. If false, return a range including all possible result values.

Definition at line 9516 of file SemaChecking.cpp.

References clang::C, E, clang::Expr::EvaluateAsRValue(), GetExprRange(), GetExprType(), clang::Expr::getSourceBitField(), clang::Expr::getType(), GetValueRange(), clang::Expr::IgnoreParens(), clang::Type::isUnsignedIntegerOrEnumerationType(), clang::Type::isVoidType(), log2, clang::T, and clang::Expr::EvalResult::Val.

Referenced by AnalyzeComparison(), clang::Sema::CheckImplicitConversion(), CheckTautologicalComparison(), and GetExprRange().

◆ GetExprType()

static QualType GetExprType ( const Expr E)
static

Definition at line 9501 of file SemaChecking.cpp.

References E, clang::Type::getAs(), and clang::Expr::getType().

Referenced by GetExprRange().

◆ getIntegerLiteral()

static const IntegerLiteral * getIntegerLiteral ( Expr E)
static

Definition at line 10727 of file SemaChecking.cpp.

References E.

Referenced by DiagnoseIntInBoolContext().

◆ getLargerAbsoluteValueFunction()

static unsigned getLargerAbsoluteValueFunction ( unsigned  AbsFunction)
static

Definition at line 7919 of file SemaChecking.cpp.

Referenced by getBestAbsFunction().

◆ GetMatchingCType()

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 
)
static

Retrieve the C type corresponding to type tag TypeExpr.

Parameters
TypeExprExpression that specifies a type tag.
MagicValuesRegistered magic values.
FoundWrongKindSet to true if a type tag was found, but of a wrong kind.
TypeInfoInformation about the corresponding C type.
isConstantEvaluatedwhether the evalaution should be performed in constant context.
Returns
true if the corresponding C type was found.

Definition at line 13978 of file SemaChecking.cpp.

References FindTypeTagExpr(), and clang::Decl::getAttr().

◆ getPresumedAlignmentOfPointer()

static CharUnits getPresumedAlignmentOfPointer ( const Expr E,
Sema S 
)
static

◆ getSizeOfArgType()

static QualType getSizeOfArgType ( const Expr E)
static

If E is a sizeof expression, returns its argument type.

Definition at line 8487 of file SemaChecking.cpp.

References E, getAsSizeOfExpr(), and SizeOf.

◆ getSizeOfExprArg()

static const Expr * getSizeOfExprArg ( const Expr E)
static

If E is a sizeof expression, returns its argument expression, otherwise returns NULL.

Definition at line 8479 of file SemaChecking.cpp.

References E, getAsSizeOfExpr(), and SizeOf.

◆ getStrlenExprArg()

static const Expr * getStrlenExprArg ( const Expr E)
static

Definition at line 8972 of file SemaChecking.cpp.

References E, and clang::FunctionDecl::getMemoryFunctionKind().

◆ GetValueRange() [1/2]

static IntRange GetValueRange ( ASTContext C,
APValue result,
QualType  Ty,
unsigned  MaxWidth 
)
static

◆ GetValueRange() [2/2]

static IntRange GetValueRange ( ASTContext C,
llvm::APSInt value,
unsigned  MaxWidth 
)
static

Definition at line 9459 of file SemaChecking.cpp.

Referenced by GetExprRange(), and GetValueRange().

◆ handleFormatSignedness()

◆ HasEnumType()

static bool HasEnumType ( Expr E)
static

Definition at line 9963 of file SemaChecking.cpp.

References E, clang::Expr::getType(), and clang::Type::isEnumeralType().

Referenced by CheckTautologicalComparison().

◆ ignoreLiteralAdditions()

static const Expr * ignoreLiteralAdditions ( const Expr Ex,
ASTContext Ctx 
)
static

◆ isArgumentExpandedFromMacro()

static bool isArgumentExpandedFromMacro ( SourceManager SM,
SourceLocation  CallLoc,
SourceLocation  ArgLoc 
)
static

Check if the ArgLoc originated from a macro passed to the call at CallLoc.

#define MACRO 0
foo(MACRO);
foo(0);

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 8610 of file SemaChecking.cpp.

References clang::SourceLocation::isMacroID(), and SM.

Referenced by CheckMemaccessSize().

◆ isArithmeticArgumentPromotion()

static bool isArithmeticArgumentPromotion ( Sema S,
const ImplicitCastExpr ICE 
)
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 7219 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().

◆ isConstantSizeArrayWithMoreThanOneElement()

static bool isConstantSizeArrayWithMoreThanOneElement ( QualType  Ty,
ASTContext Context 
)
static

◆ IsEnumConstOrFromMacro()

static bool IsEnumConstOrFromMacro ( Sema S,
Expr E 
)
static

◆ IsImplicitBoolFloatConversion()

static bool IsImplicitBoolFloatConversion ( Sema S,
Expr Ex,
bool  ToBool 
)
static

◆ IsInAnyMacroBody()

static bool IsInAnyMacroBody ( const SourceManager SM,
SourceLocation  Loc 
)
static

◆ IsInfOrNanFunction()

static bool IsInfOrNanFunction ( StringRef  calleeName,
MathCheck  Check 
)
static

Definition at line 8222 of file SemaChecking.cpp.

◆ isKnownToHaveUnsignedValue()

static bool isKnownToHaveUnsignedValue ( Expr E)
static

◆ isLayoutCompatible() [1/4]

static bool isLayoutCompatible ( const ASTContext C,
const EnumDecl ED1,
const EnumDecl ED2 
)
static

Check if two enumeration types are layout-compatible.

Definition at line 13712 of file SemaChecking.cpp.

References clang::C, clang::EnumDecl::getIntegerType(), and clang::EnumDecl::isComplete().

◆ isLayoutCompatible() [2/4]

static bool isLayoutCompatible ( const ASTContext C,
const FieldDecl Field1,
const FieldDecl Field2,
bool  AreUnionMembers = false 
)
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 13724 of file SemaChecking.cpp.

References clang::C, clang::FieldDecl::getBitWidthValue(), clang::Decl::getMaxAlignment(), clang::FieldDecl::getParent(), clang::ValueDecl::getType(), clang::TypeDecl::getTypeForDecl(), clang::Decl::hasAttr(), clang::FieldDecl::isBitField(), isLayoutCompatible(), clang::Type::isStructureOrClassType(), and clang::Type::isUnionType().

◆ isLayoutCompatible() [3/4]

static bool isLayoutCompatible ( const ASTContext C,
const RecordDecl RD1,
const RecordDecl RD2 
)
static

◆ isLayoutCompatible() [4/4]

static bool isLayoutCompatible ( const ASTContext C,
QualType  T1,
QualType  T2 
)
static

◆ isLayoutCompatibleStruct()

static bool isLayoutCompatibleStruct ( const ASTContext C,
const RecordDecl RD1,
const RecordDecl RD2 
)
static

Check if two standard-layout structs are layout-compatible.

(C++11 [class.mem] p17)

Definition at line 13768 of file SemaChecking.cpp.

References clang::C, and clang::RecordDecl::fields().

Referenced by isLayoutCompatible().

◆ isLayoutCompatibleUnion()

static bool isLayoutCompatibleUnion ( const ASTContext C,
const RecordDecl RD1,
const RecordDecl RD2 
)
static

Check if two standard-layout unions are layout-compatible.

(C++11 [class.mem] p18)

Definition at line 13786 of file SemaChecking.cpp.

References clang::C, E, clang::RecordDecl::fields(), isLayoutCompatible(), and clang::Result.

Referenced by isLayoutCompatible().

◆ isNonNullType()

static bool isNonNullType ( QualType  type)
static

Determine whether the given type has a non-null nullability annotation.

Definition at line 3028 of file SemaChecking.cpp.

References clang::NonNull, and clang::ast_matchers::type.

Referenced by CheckNonNullArguments().

◆ IsSameCharType()

static bool IsSameCharType ( QualType  T1,
QualType  T2 
)
static

Definition at line 14035 of file SemaChecking.cpp.

References clang::Type::getAs(), and clang::BuiltinType::getKind().

◆ IsSameFloatAfterCast() [1/2]

static bool IsSameFloatAfterCast ( const APValue value,
const llvm::fltSemantics &  Src,
const llvm::fltSemantics &  Tgt 
)
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 9790 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().

◆ IsSameFloatAfterCast() [2/2]

static bool IsSameFloatAfterCast ( const llvm::APFloat &  value,
const llvm::fltSemantics &  Src,
const llvm::fltSemantics &  Tgt 
)
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 9773 of file SemaChecking.cpp.

Referenced by clang::Sema::CheckImplicitConversion(), and IsSameFloatAfterCast().

◆ isSameWidthConstantConversion()

static bool isSameWidthConstantConversion ( Sema S,
Expr E,
QualType  T,
SourceLocation  CC 
)
static

◆ IsShiftedByte()

static bool IsShiftedByte ( llvm::APSInt  Value)
static

◆ IsStdFunction()

template<std::size_t StrLen>
static bool IsStdFunction ( const FunctionDecl FDecl,
const char(&)  Str[StrLen] 
)
static

◆ isValidOrderingForOp()

static bool isValidOrderingForOp ( int64_t  Ordering,
AtomicExpr::AtomicOp  Op 
)
static

Definition at line 3499 of file SemaChecking.cpp.

Referenced by clang::Sema::BuildAtomicExpr().

◆ maybeConstEvalStringLiteral()

static const Expr * maybeConstEvalStringLiteral ( ASTContext Context,
const Expr E 
)
static

Definition at line 6034 of file SemaChecking.cpp.

References E, clang::Expr::EvaluateAsRValue(), and clang::Result.

Referenced by checkFormatStringExpr().

◆ PointerAuthAuthAndResign()

static ExprResult PointerAuthAuthAndResign ( Sema S,
CallExpr Call 
)
static

◆ PointerAuthBlendDiscriminator()

static ExprResult PointerAuthBlendDiscriminator ( Sema S,
CallExpr Call 
)
static

◆ PointerAuthSignGenericData()

static ExprResult PointerAuthSignGenericData ( Sema S,
CallExpr Call 
)
static

◆ PointerAuthSignOrAuth()

static ExprResult PointerAuthSignOrAuth ( Sema S,
CallExpr Call,
PointerAuthOpKind  OpKind,
bool  RequireConstant 
)
static

◆ PointerAuthStringDiscriminator()

static ExprResult PointerAuthStringDiscriminator ( Sema S,
CallExpr Call 
)
static

◆ PointerAuthStrip()

static ExprResult PointerAuthStrip ( Sema S,
CallExpr Call 
)
static

◆ PrettyPrintInRange()

static std::string PrettyPrintInRange ( const llvm::APSInt Value,
IntRange  Range 
)
static

Definition at line 10603 of file SemaChecking.cpp.

References Range, and toString().

Referenced by clang::Sema::CheckImplicitConversion().

◆ ProcessFormatStringLiteral()

static bool ProcessFormatStringLiteral ( const Expr FormatExpr,
StringRef &  FormatStrRef,
size_t StrLen,
ASTContext Context 
)
static

Definition at line 1121 of file SemaChecking.cpp.

References clang::ASTContext::getAsConstantArrayType(), and clang::T.

◆ referToTheSameDecl()

static bool referToTheSameDecl ( const Expr E1,
const Expr E2 
)
static

Check if two expressions refer to the same declaration.

Definition at line 8965 of file SemaChecking.cpp.

◆ requiresParensToAddCast()

static bool requiresParensToAddCast ( const Expr E)
static

Definition at line 7123 of file SemaChecking.cpp.

References E, clang::Stmt::getStmtClass(), and clang::Expr::IgnoreImpCasts().

◆ ShouldDiagnoseEmptyStmtBody()

static bool ShouldDiagnoseEmptyStmtBody ( const SourceManager SourceMgr,
SourceLocation  StmtLoc,
const NullStmt Body 
)
static

◆ shouldNotPrintDirectly()

static std::pair< QualType, StringRef > shouldNotPrintDirectly ( const ASTContext Context,
QualType  IntendedTy,
const Expr E 
)
static

◆ sumOffsets()

static void sumOffsets ( llvm::APSInt Offset,
llvm::APSInt  Addend,
BinaryOperatorKind  BinOpKind,
bool  AddendIsRight 
)
static

Definition at line 5562 of file SemaChecking.cpp.

References sumOffsets().

Referenced by checkFormatStringExpr(), and sumOffsets().