16#include "llvm/ADT/StringMap.h"
31 for (
const auto *Field : BaseClassDecl->
fields())
36 for (
const auto &I : BaseClassDecl->
bases()) {
42 MostDerivedClassDecl))
46 if (BaseClassDecl == MostDerivedClassDecl) {
48 for (
const auto &I : BaseClassDecl->
vbases()) {
49 const auto *
VirtualBase = I.getType()->castAsCXXRecordDecl();
60 QualType FieldBaseElementType = Context.getBaseElementType(Field->getType());
67 if (FieldClassDecl->isUnion() && FieldClassDecl->isAnonymousStructOrUnion())
86 if (!Dtor->hasTrivialBody())
90 for (
const auto *Field : ClassDecl->
fields())
98 if (!LangOpts.Exceptions)
102 if (LangOpts.CXXExceptions)
106 if (LangOpts.ObjCExceptions) {
131 if (BuiltinID == X86::BI__builtin_ia32_cmpps ||
132 BuiltinID == X86::BI__builtin_ia32_cmpss ||
133 BuiltinID == X86::BI__builtin_ia32_cmppd ||
134 BuiltinID == X86::BI__builtin_ia32_cmpsd) {
135 llvm::StringMap<bool> TargetFeatureMap;
137 llvm::APSInt
Result = *(E->
getArg(2)->getIntegerConstantExpr(Ctx));
138 if (
Result.getSExtValue() > 7 && !TargetFeatureMap.lookup(
"avx"))
153 if (!TargetDecl || !Caller)
156 bool IsAlwaysInline = TargetDecl->
hasAttr<AlwaysInlineAttr>();
157 bool IsFlatten = Caller->
hasAttr<FlattenAttr>();
160 std::string MissingFeature;
161 llvm::StringMap<bool> CallerFeatureMap;
167 bool IsHipStdPar = LangOpts.HIPStdPar && LangOpts.CUDAIsDevice;
173 Diags.
Report(Loc, diag::err_builtin_needs_feature)
176 TargetDecl->
hasAttr<TargetAttr>()) {
178 const TargetAttr *TD = TargetDecl->
getAttr<TargetAttr>();
182 llvm::StringMap<bool> CalleeFeatureMap;
186 if (F[0] ==
'+' && CalleeFeatureMap.lookup(F.substr(1)))
187 ReqFeatures.push_back(StringRef(F).substr(1));
189 for (
const auto &F : CalleeFeatureMap) {
191 ReqFeatures.push_back(F.getKey());
193 if (!llvm::all_of(ReqFeatures,
195 if (!CallerFeatureMap.lookup(
Feature)) {
196 MissingFeature =
Feature.str();
203 Diags.
Report(Loc, diag::err_function_needs_feature)
207 Diags.
Report(Loc, diag::err_flatten_function_needs_feature)
212 llvm::StringMap<bool> CalleeFeatureMap;
215 for (
const auto &F : CalleeFeatureMap) {
217 (!CallerFeatureMap.lookup(F.getKey()) ||
218 !CallerFeatureMap.find(F.getKey())->getValue()) &&
221 Diags.
Report(Loc, diag::err_function_needs_feature)
225 Diags.
Report(Loc, diag::err_flatten_function_needs_feature)
Defines enum values for all the target-independent builtin functions.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
Builtin::Context & BuiltinInfo
const TargetInfo & getTargetInfo() const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
const char * getRequiredFeatures(unsigned ID) const
Represents a C++ base or member initializer.
const Type * getBaseClass() const
If this is a base class initializer, returns the type of the base class.
Represents a C++ destructor within a class.
Represents a C++ struct/union/class.
bool isEffectivelyFinal() const
Determine whether it's impossible for a class to be derived from this class.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
base_class_range vbases()
bool isDynamicClass() const
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents a member of a struct/union/class.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
bool hasTrivialBody() const
Returns whether the function has a trivial body that does not require any specific codegen.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
clang::ObjCRuntime ObjCRuntime
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
bool hasUnwindExceptions() const
Does this runtime use zero-cost exceptions?
ParsedAttr - Represents a syntactic attribute.
A (possibly-)qualified type.
field_range fields() const
Encodes a location in the source.
Exposes information about the current target.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
virtual StringRef getABI() const
Get the ABI currently in use.
The base class of the type hierarchy.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
CXXRecordDecl * castAsCXXRecordDecl() const
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
static bool hasTrivialDestructorBody(ASTContext &Context, const CXXRecordDecl *BaseClassDecl, const CXXRecordDecl *MostDerivedClassDecl)
bool isAAPCS(const TargetInfo &TargetInfo)
Helper method to check if the underlying ABI is AAPCS.
bool isInitializerOfDynamicClass(const CXXCtorInitializer *BaseInit)
bool canSkipVTablePointerInitialization(ASTContext &Ctx, const CXXDestructorDecl *Dtor)
Check whether we need to initialize any vtable pointers before calling this destructor.
bool fieldHasTrivialDestructorBody(ASTContext &Context, const FieldDecl *Field)
Check whether destructing Field has no observable behaviors, and thus can be skipped when creating a ...
bool hasUnwindExceptions(const LangOptions &LangOpts)
Determines whether the language options require us to model unwind exceptions.
void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const CallExpr *E, const FunctionDecl *Caller, const FunctionDecl *TargetDecl)
Check that a call to a target-specific builtin has the required target features enabled in the caller...
@ Result
The result type of a method or function.
Contains information gathered from parsing the contents of TargetAttr.