#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>
usingnamespaceclang;
usingnamespacesema;
SourceLocation Sema::getLocationOfStringLiteralByte(const StringLiteral *SL,
unsigned ByteNo) const { … }
static constexpr unsigned short combineFAPK(Sema::FormatArgumentPassingKind A,
Sema::FormatArgumentPassingKind B) { … }
bool Sema::checkArgCountAtLeast(CallExpr *Call, unsigned MinArgCount) { … }
bool Sema::checkArgCountAtMost(CallExpr *Call, unsigned MaxArgCount) { … }
bool Sema::checkArgCountRange(CallExpr *Call, unsigned MinArgCount,
unsigned MaxArgCount) { … }
bool Sema::checkArgCount(CallExpr *Call, unsigned DesiredArgCount) { … }
static bool checkBuiltinVerboseTrap(CallExpr *Call, Sema &S) { … }
static bool convertArgumentToType(Sema &S, Expr *&Value, QualType Ty) { … }
static bool BuiltinAnnotation(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinMSVCAnnotation(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinAddressof(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinFunctionStart(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinPreserveAI(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinAlignment(Sema &S, CallExpr *TheCall, unsigned ID) { … }
static bool BuiltinOverflow(Sema &S, CallExpr *TheCall, unsigned BuiltinID) { … }
namespace {
struct BuiltinDumpStructGenerator { … };
}
static ExprResult BuiltinDumpStruct(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinCallWithStaticChain(Sema &S, CallExpr *BuiltinCall) { … }
namespace {
class ScanfDiagnosticFormatHandler
: public analyze_format_string::FormatStringHandler { … };
class EstimateSizeFormatHandler
: public analyze_format_string::FormatStringHandler { … };
}
static bool ProcessFormatStringLiteral(const Expr *FormatExpr,
StringRef &FormatStrRef, size_t &StrLen,
ASTContext &Context) { … }
void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
CallExpr *TheCall) { … }
static bool BuiltinSEHScopeCheck(Sema &SemaRef, CallExpr *TheCall,
Scope::ScopeFlags NeededScopeFlags,
unsigned DiagID) { … }
static void builtinAllocaAddrSpace(Sema &S, CallExpr *TheCall) { … }
namespace {
enum PointerAuthOpKind { … };
}
bool Sema::checkPointerAuthEnabled(SourceLocation Loc, SourceRange Range) { … }
static bool checkPointerAuthEnabled(Sema &S, Expr *E) { … }
static bool checkPointerAuthKey(Sema &S, Expr *&Arg) { … }
bool Sema::checkConstantPointerAuthKey(Expr *Arg, unsigned &Result) { … }
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 BuiltinLaunder(Sema &S, CallExpr *TheCall) { … }
static ExprResult BuiltinIsWithinLifetime(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);
bool Sema::CheckTSBuiltinFunctionCall(const TargetInfo &TI, unsigned BuiltinID,
CallExpr *TheCall) { … }
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) { … }
static bool BuiltinPopcountg(Sema &S, CallExpr *TheCall) { … }
static bool BuiltinCountZeroBitsGeneric(Sema &S, CallExpr *TheCall) { … }
ExprResult
Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
CallExpr *TheCall) { … }
bool Sema::ValueIsRunOfOnes(CallExpr *TheCall, unsigned ArgNum) { … }
bool Sema::getFormatStringInfo(const FormatAttr *Format, bool IsCXXMember,
bool IsVariadic, FormatStringInfo *FSI) { … }
static bool CheckNonNullExpr(Sema &S, const Expr *Expr) { … }
static void CheckNonNullArgument(Sema &S,
const Expr *ArgExpr,
SourceLocation CallSiteLoc) { … }
static bool isNonNullType(QualType type) { … }
static void CheckNonNullArguments(Sema &S,
const NamedDecl *FDecl,
const FunctionProtoType *Proto,
ArrayRef<const Expr *> Args,
SourceLocation CallSiteLoc) { … }
void Sema::CheckArgAlignment(SourceLocation Loc, NamedDecl *FDecl,
StringRef ParamName, QualType ArgTy,
QualType ParamTy) { … }
void Sema::checkCall(NamedDecl *FDecl, const FunctionProtoType *Proto,
const Expr *ThisArg, ArrayRef<const Expr *> Args,
bool IsMemberFunction, SourceLocation Loc,
SourceRange Range, VariadicCallType CallType) { … }
void Sema::CheckConstrainedAuto(const AutoType *AutoT, SourceLocation Loc) { … }
void Sema::CheckConstructorCall(FunctionDecl *FDecl, QualType ThisType,
ArrayRef<const Expr *> Args,
const FunctionProtoType *Proto,
SourceLocation Loc) { … }
bool Sema::CheckFunctionCall(FunctionDecl *FDecl, CallExpr *TheCall,
const FunctionProtoType *Proto) { … }
bool Sema::CheckPointerCall(NamedDecl *NDecl, CallExpr *TheCall,
const FunctionProtoType *Proto) { … }
bool Sema::CheckOtherCall(CallExpr *TheCall, const FunctionProtoType *Proto) { … }
static bool isValidOrderingForOp(int64_t Ordering, AtomicExpr::AtomicOp Op) { … }
ExprResult Sema::AtomicOpsOverloaded(ExprResult TheCallResult,
AtomicExpr::AtomicOp Op) { … }
ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
SourceLocation RParenLoc, MultiExprArg Args,
AtomicExpr::AtomicOp Op,
AtomicArgumentOrder ArgOrder) { … }
static bool checkBuiltinArgument(Sema &S, CallExpr *E, unsigned ArgIndex) { … }
ExprResult Sema::BuiltinAtomicOverloaded(ExprResult TheCallResult) { … }
ExprResult Sema::BuiltinNontemporalOverloaded(ExprResult TheCallResult) { … }
ExprResult Sema::CheckOSLogFormatStringArg(Expr *Arg) { … }
static bool checkVAStartABI(Sema &S, unsigned BuiltinID, Expr *Fn) { … }
static bool checkVAStartIsInVariadicFunction(Sema &S, Expr *Fn,
ParmVarDecl **LastParam = nullptr) { … }
bool Sema::BuiltinVAStart(unsigned BuiltinID, CallExpr *TheCall) { … }
bool Sema::BuiltinVAStartARMMicrosoft(CallExpr *Call) { … }
bool Sema::BuiltinUnorderedCompare(CallExpr *TheCall, unsigned BuiltinID) { … }
bool Sema::BuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs,
unsigned BuiltinID) { … }
bool Sema::BuiltinComplex(CallExpr *TheCall) { … }
ExprResult Sema::BuiltinShuffleVector(CallExpr *TheCall) { … }
ExprResult Sema::ConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo,
SourceLocation BuiltinLoc,
SourceLocation RParenLoc) { … }
bool Sema::BuiltinPrefetch(CallExpr *TheCall) { … }
bool Sema::BuiltinArithmeticFence(CallExpr *TheCall) { … }
bool Sema::BuiltinAssume(CallExpr *TheCall) { … }
bool Sema::BuiltinAllocaWithAlign(CallExpr *TheCall) { … }
bool Sema::BuiltinAssumeAligned(CallExpr *TheCall) { … }
bool Sema::BuiltinOSLogFormat(CallExpr *TheCall) { … }
bool Sema::BuiltinConstantArg(CallExpr *TheCall, int ArgNum,
llvm::APSInt &Result) { … }
bool Sema::BuiltinConstantArgRange(CallExpr *TheCall, int ArgNum, int Low,
int High, bool RangeIsError) { … }
bool Sema::BuiltinConstantArgMultiple(CallExpr *TheCall, int ArgNum,
unsigned Num) { … }
bool Sema::BuiltinConstantArgPower2(CallExpr *TheCall, int ArgNum) { … }
static bool IsShiftedByte(llvm::APSInt Value) { … }
bool Sema::BuiltinConstantArgShiftedByte(CallExpr *TheCall, int ArgNum,
unsigned ArgBits) { … }
bool Sema::BuiltinConstantArgShiftedByteOrXXFF(CallExpr *TheCall, int ArgNum,
unsigned ArgBits) { … }
bool Sema::BuiltinLongjmp(CallExpr *TheCall) { … }
bool Sema::BuiltinSetjmp(CallExpr *TheCall) { … }
namespace {
class UncoveredArgHandler { … };
enum StringLiteralCheckType { … };
}
static void sumOffsets(llvm::APSInt &Offset, llvm::APSInt Addend,
BinaryOperatorKind BinOpKind,
bool AddendIsRight) { … }
namespace {
class FormatStringLiteral { … };
}
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 Expr *maybeConstEvalStringLiteral(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) { … }
static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
const Expr *E) { … }
Sema::FormatStringType Sema::GetFormatStringType(const FormatAttr *Format) { … }
bool Sema::CheckFormatArguments(const FormatAttr *Format,
ArrayRef<const Expr *> Args, bool IsCXXMember,
VariadicCallType CallType, SourceLocation Loc,
SourceRange Range,
llvm::SmallBitVector &CheckedVarArgs) { … }
bool Sema::CheckFormatArguments(ArrayRef<const Expr *> Args,
Sema::FormatArgumentPassingKind APK,
unsigned format_idx, unsigned firstDataArg,
FormatStringType Type,
VariadicCallType CallType, SourceLocation Loc,
SourceRange Range,
llvm::SmallBitVector &CheckedVarArgs) { … }
namespace {
class CheckFormatHandler : public analyze_format_string::FormatStringHandler { … };
}
SourceRange CheckFormatHandler::getFormatStringRange() { … }
CharSourceRange CheckFormatHandler::
getSpecifierRange(const char *startSpecifier, unsigned specifierLen) { … }
SourceLocation CheckFormatHandler::getLocationOfByte(const char *x) { … }
void CheckFormatHandler::HandleIncompleteSpecifier(const char *startSpecifier,
unsigned specifierLen){ … }
void CheckFormatHandler::HandleInvalidLengthModifier(
const analyze_format_string::FormatSpecifier &FS,
const analyze_format_string::ConversionSpecifier &CS,
const char *startSpecifier, unsigned specifierLen, unsigned DiagID) { … }
void CheckFormatHandler::HandleNonStandardLengthModifier(
const analyze_format_string::FormatSpecifier &FS,
const char *startSpecifier, unsigned specifierLen) { … }
void CheckFormatHandler::HandleNonStandardConversionSpecifier(
const analyze_format_string::ConversionSpecifier &CS,
const char *startSpecifier, unsigned specifierLen) { … }
void CheckFormatHandler::HandlePosition(const char *startPos,
unsigned posLen) { … }
void CheckFormatHandler::HandleInvalidPosition(
const char *startSpecifier, unsigned specifierLen,
analyze_format_string::PositionContext p) { … }
void CheckFormatHandler::HandleZeroPosition(const char *startPos,
unsigned posLen) { … }
void CheckFormatHandler::HandleNullChar(const char *nullCharacter) { … }
const Expr *CheckFormatHandler::getDataArg(unsigned i) const { … }
void CheckFormatHandler::DoneProcessing() { … }
void UncoveredArgHandler::Diagnose(Sema &S, bool IsFunctionCall,
const Expr *ArgExpr) { … }
bool
CheckFormatHandler::HandleInvalidConversionSpecifier(unsigned argIndex,
SourceLocation Loc,
const char *startSpec,
unsigned specifierLen,
const char *csStart,
unsigned csLen) { … }
void
CheckFormatHandler::HandlePositionalNonpositionalArgs(SourceLocation Loc,
const char *startSpec,
unsigned specifierLen) { … }
bool
CheckFormatHandler::CheckNumArgs(
const analyze_format_string::FormatSpecifier &FS,
const analyze_format_string::ConversionSpecifier &CS,
const char *startSpecifier, unsigned specifierLen, unsigned argIndex) { … }
template<typename Range>
void CheckFormatHandler::EmitFormatDiagnostic(PartialDiagnostic PDiag,
SourceLocation Loc,
bool IsStringLocation,
Range StringRange,
ArrayRef<FixItHint> FixIt) { … }
template <typename Range>
void CheckFormatHandler::EmitFormatDiagnostic(
Sema &S, bool InFunctionCall, const Expr *ArgumentExpr,
const PartialDiagnostic &PDiag, SourceLocation Loc, bool IsStringLocation,
Range StringRange, ArrayRef<FixItHint> FixIt) { … }
namespace {
class CheckPrintfHandler : public CheckFormatHandler { … };
}
bool CheckPrintfHandler::HandleInvalidPrintfConversionSpecifier(
const analyze_printf::PrintfSpecifier &FS,
const char *startSpecifier,
unsigned specifierLen) { … }
void CheckPrintfHandler::handleInvalidMaskType(StringRef MaskType) { … }
bool CheckPrintfHandler::HandleAmount(
const analyze_format_string::OptionalAmount &Amt, unsigned k,
const char *startSpecifier, unsigned specifierLen) { … }
void CheckPrintfHandler::HandleInvalidAmount(
const analyze_printf::PrintfSpecifier &FS,
const analyze_printf::OptionalAmount &Amt,
unsigned type,
const char *startSpecifier,
unsigned specifierLen) { … }
void CheckPrintfHandler::HandleFlag(const analyze_printf::PrintfSpecifier &FS,
const analyze_printf::OptionalFlag &flag,
const char *startSpecifier,
unsigned specifierLen) { … }
void CheckPrintfHandler::HandleIgnoredFlag(
const analyze_printf::PrintfSpecifier &FS,
const analyze_printf::OptionalFlag &ignoredFlag,
const analyze_printf::OptionalFlag &flag,
const char *startSpecifier,
unsigned specifierLen) { … }
void CheckPrintfHandler::HandleEmptyObjCModifierFlag(const char *startFlag,
unsigned flagLen) { … }
void CheckPrintfHandler::HandleInvalidObjCModifierFlag(const char *startFlag,
unsigned flagLen) { … }
void CheckPrintfHandler::HandleObjCFlagsWithNonObjCConversion(
const char *flagsStart, const char *flagsEnd, const char *conversionPosition) { … }
template<typename MemberKind>
static llvm::SmallPtrSet<MemberKind*, 1>
CXXRecordMembersNamed(StringRef Name, Sema &S, QualType Ty) { … }
bool Sema::hasCStrMethod(const Expr *E) { … }
bool CheckPrintfHandler::checkForCStrMembers(
const analyze_printf::ArgType &AT, const Expr *E) { … }
bool CheckPrintfHandler::HandlePrintfSpecifier(
const analyze_printf::PrintfSpecifier &FS, const char *startSpecifier,
unsigned specifierLen, const TargetInfo &Target) { … }
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) { … }
static analyze_format_string::ArgType::MatchKind
handleFormatSignedness(analyze_format_string::ArgType::MatchKind Match,
DiagnosticsEngine &Diags, SourceLocation Loc) { … }
bool
CheckPrintfHandler::checkFormatExpr(const analyze_printf::PrintfSpecifier &FS,
const char *StartSpecifier,
unsigned SpecifierLen,
const Expr *E) { … }
namespace {
class CheckScanfHandler : public CheckFormatHandler { … };
}
void CheckScanfHandler::HandleIncompleteScanList(const char *start,
const char *end) { … }
bool CheckScanfHandler::HandleInvalidScanfConversionSpecifier(
const analyze_scanf::ScanfSpecifier &FS,
const char *startSpecifier,
unsigned specifierLen) { … }
bool CheckScanfHandler::HandleScanfSpecifier(
const analyze_scanf::ScanfSpecifier &FS,
const char *startSpecifier,
unsigned specifierLen) { … }
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) { … }
bool Sema::FormatStringHasSArg(const StringLiteral *FExpr) { … }
static unsigned getLargerAbsoluteValueFunction(unsigned AbsFunction) { … }
static QualType getAbsoluteValueArgumentType(ASTContext &Context,
unsigned AbsType) { … }
static unsigned getBestAbsFunction(ASTContext &Context, QualType ArgType,
unsigned AbsFunctionKind) { … }
enum AbsoluteValueKind { … };
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]) { … }
enum class MathCheck { … };
static bool IsInfOrNanFunction(StringRef calleeName, MathCheck Check) { … }
void Sema::CheckInfNaNFunction(const CallExpr *Call,
const FunctionDecl *FDecl) { … }
void Sema::CheckAbsoluteValueFunction(const CallExpr *Call,
const FunctionDecl *FDecl) { … }
void Sema::CheckMaxUnsignedZero(const CallExpr *Call,
const FunctionDecl *FDecl) { … }
static bool CheckMemorySizeofForComparison(Sema &S, const Expr *E,
IdentifierInfo *FnName,
SourceLocation FnLoc,
SourceLocation RParenLoc) { … }
static const CXXRecordDecl *getContainedDynamicClass(QualType T,
bool &IsContained) { … }
static const UnaryExprOrTypeTraitExpr *getAsSizeOfExpr(const Expr *E) { … }
static const Expr *getSizeOfExprArg(const Expr *E) { … }
static QualType getSizeOfArgType(const Expr *E) { … }
namespace {
struct SearchNonTrivialToInitializeField
: DefaultInitializedTypeVisitor<SearchNonTrivialToInitializeField> { … };
struct SearchNonTrivialToCopyField
: CopiedTypeVisitor<SearchNonTrivialToCopyField, false> { … };
}
static bool doesExprLikelyComputeSize(const Expr *SizeofExpr) { … }
static bool isArgumentExpandedFromMacro(SourceManager &SM,
SourceLocation CallLoc,
SourceLocation ArgLoc) { … }
static void CheckMemaccessSize(Sema &S, unsigned BId, const CallExpr *Call) { … }
void Sema::CheckMemaccessArguments(const CallExpr *Call,
unsigned BId,
IdentifierInfo *FnName) { … }
static const Expr *ignoreLiteralAdditions(const Expr *Ex, ASTContext &Ctx) { … }
static bool isConstantSizeArrayWithMoreThanOneElement(QualType Ty,
ASTContext &Context) { … }
void Sema::CheckStrlcpycatArguments(const CallExpr *Call,
IdentifierInfo *FnName) { … }
static bool referToTheSameDecl(const Expr *E1, const Expr *E2) { … }
static const Expr *getStrlenExprArg(const Expr *E) { … }
void Sema::CheckStrncatArguments(const CallExpr *CE,
IdentifierInfo *FnName) { … }
namespace {
void CheckFreeArgumentsOnLvalue(Sema &S, const std::string &CalleeName,
const UnaryOperator *UnaryExpr, const Decl *D) { … }
void CheckFreeArgumentsAddressof(Sema &S, const std::string &CalleeName,
const UnaryOperator *UnaryExpr) { … }
void CheckFreeArgumentsPlus(Sema &S, const std::string &CalleeName,
const UnaryOperator *UnaryExpr) { … }
void CheckFreeArgumentsStackArray(Sema &S, const std::string &CalleeName,
const DeclRefExpr *Lvalue) { … }
void CheckFreeArgumentsCast(Sema &S, const std::string &CalleeName,
const CastExpr *Cast) { … }
}
void Sema::CheckFreeArguments(const CallExpr *E) { … }
void
Sema::CheckReturnValExpr(Expr *RetValExp, QualType lhsType,
SourceLocation ReturnLoc,
bool isObjCMethod,
const AttrVec *Attrs,
const FunctionDecl *FD) { … }
void Sema::CheckFloatComparison(SourceLocation Loc, Expr *LHS, Expr *RHS,
BinaryOperatorKind Opcode) { … }
namespace {
struct IntRange { … };
}
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) { … }
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) { … }
static bool IsSameFloatAfterCast(const APValue &value,
const llvm::fltSemantics &Src,
const llvm::fltSemantics &Tgt) { … }
static void AnalyzeImplicitConversions(Sema &S, Expr *E, SourceLocation CC,
bool IsListInit = false);
static bool IsEnumConstOrFromMacro(Sema &S, Expr *E) { … }
static bool isKnownToHaveUnsignedValue(Expr *E) { … }
namespace {
struct PromotedRange { … };
}
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) { … }
static void AnalyzeComparison(Sema &S, BinaryOperator *E) { … }
static bool AnalyzeBitFieldAssignment(Sema &S, FieldDecl *Bitfield, Expr *Init,
SourceLocation InitLoc) { … }
static void AnalyzeAssignment(Sema &S, BinaryOperator *E) { … }
static void DiagnoseImpCast(Sema &S, Expr *E, QualType SourceType, QualType T,
SourceLocation CContext, unsigned diag,
bool pruneControlFlow = false) { … }
static void DiagnoseImpCast(Sema &S, Expr *E, QualType T,
SourceLocation CContext,
unsigned diag, bool pruneControlFlow = false) { … }
static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
SourceLocation CContext) { … }
static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) { … }
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 IntegerLiteral *getIntegerLiteral(Expr *E) { … }
static void DiagnoseIntInBoolContext(Sema &S, Expr *E) { … }
void Sema::CheckImplicitConversion(Expr *E, QualType T, SourceLocation CC,
bool *ICContext, bool IsListInit) { … }
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 CheckConditionalOperator(Sema &S, AbstractConditionalOperator *E,
SourceLocation CC, QualType T) { … }
static void CheckBoolLikeConversion(Sema &S, Expr *E, SourceLocation CC) { … }
namespace {
struct AnalyzeImplicitConversionsWorkItem { … };
}
static void AnalyzeImplicitConversions(
Sema &S, AnalyzeImplicitConversionsWorkItem Item,
llvm::SmallVectorImpl<AnalyzeImplicitConversionsWorkItem> &WorkList) { … }
static void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC,
bool IsListInit) { … }
static bool CheckForReference(Sema &SemaRef, const Expr *E,
const PartialDiagnostic &PD) { … }
static bool IsInAnyMacroBody(const SourceManager &SM, SourceLocation Loc) { … }
void Sema::DiagnoseAlwaysNonNullPointer(Expr *E,
Expr::NullPointerConstantKind NullKind,
bool IsEqual, SourceRange Range) { … }
void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) { … }
void Sema::CheckBoolLikeConversion(Expr *E, SourceLocation CC) { … }
void Sema::CheckForIntOverflow (const Expr *E) { … }
namespace {
class SequenceChecker : public ConstEvaluatedExprVisitor<SequenceChecker> { … };
SequenceChecker::UsageInfo::UsageInfo() = default;
}
void Sema::CheckUnsequencedOperations(const Expr *E) { … }
void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc,
bool IsConstexpr) { … }
void Sema::CheckBitFieldInitialization(SourceLocation InitLoc,
FieldDecl *BitField,
Expr *Init) { … }
static void diagnoseArrayStarInParamType(Sema &S, QualType PType,
SourceLocation Loc) { … }
bool Sema::CheckParmsForFunctionDef(ArrayRef<ParmVarDecl *> Parameters,
bool CheckParameterNames) { … }
std::optional<std::pair<
CharUnits, CharUnits>> static getBaseAlignmentAndOffsetFromPtr(const Expr
*E,
ASTContext
&Ctx);
static std::pair<CharUnits, CharUnits>
getDerivedToBaseAlignmentAndOffset(const CastExpr *CE, QualType DerivedType,
CharUnits BaseAlignment, CharUnits Offset,
ASTContext &Ctx) { … }
static std::optional<std::pair<CharUnits, CharUnits>>
getAlignmentAndOffsetFromBinAddOrSub(const Expr *PtrE, const Expr *IntE,
bool IsSub, ASTContext &Ctx) { … }
std::optional<std::pair<
CharUnits,
CharUnits>> static getBaseAlignmentAndOffsetFromLValue(const Expr *E,
ASTContext &Ctx) { … }
std::optional<std::pair<
CharUnits, CharUnits>> static getBaseAlignmentAndOffsetFromPtr(const Expr
*E,
ASTContext
&Ctx) { … }
static CharUnits getPresumedAlignmentOfPointer(const Expr *E, Sema &S) { … }
void Sema::CheckCastAlign(Expr *Op, QualType T, SourceRange TRange) { … }
void Sema::CheckArrayAccess(const Expr *BaseExpr, const Expr *IndexExpr,
const ArraySubscriptExpr *ASE,
bool AllowOnePastEnd, bool IndexNegated) { … }
void Sema::CheckArrayAccess(const Expr *expr) { … }
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) { … }
bool Sema::checkUnsafeAssigns(SourceLocation Loc,
QualType LHS, Expr *RHS) { … }
void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
Expr *LHS, Expr *RHS) { … }
static bool ShouldDiagnoseEmptyStmtBody(const SourceManager &SourceMgr,
SourceLocation StmtLoc,
const NullStmt *Body) { … }
void Sema::DiagnoseEmptyStmtBody(SourceLocation StmtLoc,
const Stmt *Body,
unsigned DiagID) { … }
void Sema::DiagnoseEmptyLoopBody(const Stmt *S,
const Stmt *PossibleBody) { … }
void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr,
SourceLocation OpLoc) { … }
static bool isLayoutCompatible(const ASTContext &C, QualType T1, QualType T2);
static bool isLayoutCompatible(const ASTContext &C, const EnumDecl *ED1,
const EnumDecl *ED2) { … }
static bool isLayoutCompatible(const ASTContext &C, const FieldDecl *Field1,
const FieldDecl *Field2,
bool AreUnionMembers = false) { … }
static bool isLayoutCompatibleStruct(const ASTContext &C, const RecordDecl *RD1,
const RecordDecl *RD2) { … }
static bool isLayoutCompatibleUnion(const ASTContext &C, const RecordDecl *RD1,
const RecordDecl *RD2) { … }
static bool isLayoutCompatible(const ASTContext &C, const RecordDecl *RD1,
const RecordDecl *RD2) { … }
static bool isLayoutCompatible(const ASTContext &C, QualType T1, QualType T2) { … }
bool Sema::IsLayoutCompatible(QualType T1, QualType T2) const { … }
bool Sema::IsPointerInterconvertibleBaseOf(const TypeSourceInfo *Base,
const TypeSourceInfo *Derived) { … }
static bool FindTypeTagExpr(const Expr *TypeExpr, const ASTContext &Ctx,
const ValueDecl **VD, uint64_t *MagicValue,
bool isConstantEvaluated) { … }
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) { … }
void Sema::RegisterTypeTagForDatatype(const IdentifierInfo *ArgumentKind,
uint64_t MagicValue, QualType Type,
bool LayoutCompatible,
bool MustBeNull) { … }
static bool IsSameCharType(QualType T1, QualType T2) { … }
void Sema::CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
const ArrayRef<const Expr *> ExprArgs,
SourceLocation CallSiteLoc) { … }
void Sema::AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl *MD,
CharUnits Alignment) { … }
void Sema::DiagnoseMisalignedMembers() { … }
void Sema::DiscardMisalignedMemberAddress(const Type *T, Expr *E) { … }
void Sema::RefersToMemberWithReducedAlignment(
Expr *E,
llvm::function_ref<void(Expr *, RecordDecl *, FieldDecl *, CharUnits)>
Action) { … }
void Sema::CheckAddressOfPackedMember(Expr *rhs) { … }
bool Sema::PrepareBuiltinElementwiseMathOneArgCall(CallExpr *TheCall) { … }
bool Sema::BuiltinElementwiseMath(CallExpr *TheCall) { … }
bool Sema::BuiltinVectorToScalarMath(CallExpr *TheCall) { … }
bool Sema::BuiltinVectorMath(CallExpr *TheCall, QualType &Res) { … }
bool Sema::BuiltinElementwiseTernaryMath(CallExpr *TheCall,
bool CheckForFloatArgs) { … }
bool Sema::PrepareBuiltinReduceMathOneArgCall(CallExpr *TheCall) { … }
bool Sema::BuiltinNonDeterministicValue(CallExpr *TheCall) { … }
ExprResult Sema::BuiltinMatrixTranspose(CallExpr *TheCall,
ExprResult CallResult) { … }
static std::optional<unsigned>
getAndVerifyMatrixDimension(Expr *Expr, StringRef Name, Sema &S) { … }
ExprResult Sema::BuiltinMatrixColumnMajorLoad(CallExpr *TheCall,
ExprResult CallResult) { … }
ExprResult Sema::BuiltinMatrixColumnMajorStore(CallExpr *TheCall,
ExprResult CallResult) { … }
void Sema::CheckTCBEnforcement(const SourceLocation CallExprLoc,
const NamedDecl *Callee) { … }