22void LoopHintAttr::printPrettyPragma(raw_ostream &OS,
24 unsigned SpellingIndex = getAttributeSpellingListIndex();
27 if (SpellingIndex == Pragma_nounroll ||
28 SpellingIndex == Pragma_nounroll_and_jam)
30 else if (SpellingIndex == Pragma_unroll ||
31 SpellingIndex == Pragma_unroll_and_jam) {
32 OS <<
' ' << getValueString(Policy);
36 assert(SpellingIndex == Pragma_clang_loop &&
"Unexpected spelling");
37 OS <<
' ' << getOptionName(option) << getValueString(Policy);
42std::string LoopHintAttr::getValueString(
const PrintingPolicy &Policy)
const {
43 std::string ValueName;
44 llvm::raw_string_ostream
OS(ValueName);
47 value->printPretty(OS,
nullptr, Policy);
48 else if (state == FixedWidth || state == ScalableWidth) {
50 value->printPretty(OS,
nullptr, Policy);
51 if (state == ScalableWidth)
53 }
else if (state == ScalableWidth)
57 }
else if (state == Enable)
59 else if (state == Full)
61 else if (state == AssumeSafety)
62 OS <<
"assume_safety";
71LoopHintAttr::getDiagnosticName(
const PrintingPolicy &Policy)
const {
72 unsigned SpellingIndex = getAttributeSpellingListIndex();
73 if (SpellingIndex == Pragma_nounroll)
74 return "#pragma nounroll";
75 else if (SpellingIndex == Pragma_unroll)
76 return "#pragma unroll" +
77 (option == UnrollCount ? getValueString(Policy) :
"");
78 else if (SpellingIndex == Pragma_nounroll_and_jam)
79 return "#pragma nounroll_and_jam";
80 else if (SpellingIndex == Pragma_unroll_and_jam)
81 return "#pragma unroll_and_jam" +
82 (option == UnrollAndJamCount ? getValueString(Policy) :
"");
84 assert(SpellingIndex == Pragma_clang_loop &&
"Unexpected spelling");
85 return getOptionName(option) + getValueString(Policy);
88void OMPDeclareSimdDeclAttr::printPrettyPragma(
90 if (getBranchState() != BS_Undefined)
91 OS <<
' ' << ConvertBranchStateTyToStr(getBranchState());
92 if (
auto *E = getSimdlen()) {
94 E->printPretty(OS,
nullptr, Policy);
97 if (uniforms_size() > 0) {
100 for (
auto *E : uniforms()) {
102 E->printPretty(OS,
nullptr, Policy);
107 alignments_iterator NI = alignments_begin();
108 for (
auto *E : aligneds()) {
110 E->printPretty(OS,
nullptr, Policy);
113 (*NI)->printPretty(OS,
nullptr, Policy);
118 steps_iterator I = steps_begin();
119 modifiers_iterator MI = modifiers_begin();
120 for (
auto *E : linears()) {
125 E->printPretty(OS,
nullptr, Policy);
130 (*I)->printPretty(OS,
nullptr, Policy);
138void OMPDeclareTargetDeclAttr::printPrettyPragma(
141 if (getDevType() != DT_Any)
142 OS <<
" device_type(" << ConvertDevTypeTyToStr(getDevType()) <<
")";
143 if (getMapType() != MT_To && getMapType() != MT_Enter)
144 OS <<
' ' << ConvertMapTypeTyToStr(getMapType());
145 if (
Expr *E = getIndirectExpr()) {
147 E->printPretty(OS,
nullptr, Policy);
149 }
else if (getIndirect()) {
154std::optional<OMPDeclareTargetDeclAttr *>
155OMPDeclareTargetDeclAttr::getActiveAttr(
const ValueDecl *VD) {
156 if (llvm::all_of(VD->
redecls(), [](
const Decl *D) { return !D->hasAttrs(); }))
159 OMPDeclareTargetDeclAttr *FoundAttr =
nullptr;
162 if (Level <= Attr->getLevel()) {
163 Level =
Attr->getLevel();
173std::optional<OMPDeclareTargetDeclAttr::MapTypeTy>
174OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(
const ValueDecl *VD) {
175 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
177 return (*ActiveAttr)->getMapType();
181std::optional<OMPDeclareTargetDeclAttr::DevTypeTy>
182OMPDeclareTargetDeclAttr::getDeviceType(
const ValueDecl *VD) {
183 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
185 return (*ActiveAttr)->getDevType();
189std::optional<SourceLocation>
190OMPDeclareTargetDeclAttr::getLocation(
const ValueDecl *VD) {
191 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
193 return (*ActiveAttr)->getRange().getBegin();
198llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const OMPTraitInfo &TI);
199llvm::raw_ostream &
operator<<(llvm::raw_ostream &OS,
const OMPTraitInfo *TI);
202void OMPDeclareVariantAttr::printPrettyPragma(
204 if (
const Expr *E = getVariantFuncRef()) {
206 E->printPretty(OS,
nullptr, Policy);
209 OS <<
" match(" << traitInfos <<
")";
211 auto PrintExprs = [&
OS, &Policy](
Expr **Begin,
Expr **End) {
212 for (
Expr **I = Begin; I != End; ++I) {
213 assert(*I &&
"Expected non-null Stmt");
216 (*I)->printPretty(OS,
nullptr, Policy);
219 if (adjustArgsNothing_size()) {
220 OS <<
" adjust_args(nothing:";
221 PrintExprs(adjustArgsNothing_begin(), adjustArgsNothing_end());
224 if (adjustArgsNeedDevicePtr_size()) {
225 OS <<
" adjust_args(need_device_ptr:";
226 PrintExprs(adjustArgsNeedDevicePtr_begin(), adjustArgsNeedDevicePtr_end());
229 if (adjustArgsNeedDeviceAddr_size()) {
230 OS <<
" adjust_args(need_device_addr:";
231 PrintExprs(adjustArgsNeedDeviceAddr_begin(),
232 adjustArgsNeedDeviceAddr_end());
241 OS << getInteropTypeString(I);
245 if (appendArgs_size()) {
246 OS <<
" append_args(";
247 PrintInteropInfo(appendArgs_begin(), appendArgs_end());
252unsigned AlignedAttr::getAlignment(
ASTContext &Ctx)
const {
253 assert(!isAlignmentDependent());
254 if (getCachedAlignmentValue())
255 return *getCachedAlignmentValue();
258 if (!isAlignmentExpr()) {
259 QualType T = getAlignmentType()->getType();
264 T =
T.getNonReferenceType();
266 if (
T.getQualifiers().hasUnaligned())
275 return alignmentExpr->EvaluateKnownConstInt(Ctx).getZExtValue() *
292#define USE_DEFAULT_EQUALITY \
293 (std::is_same_v<T, StringRef> || std::is_same_v<T, VersionTuple> || \
294 std::is_same_v<T, IdentifierInfo *> || std::is_same_v<T, ParamIdx> || \
295 std::is_same_v<T, Attr *> || std::is_same_v<T, char *> || \
296 std::is_enum_v<T> || std::is_integral_v<T>)
299typename std::enable_if_t<!USE_DEFAULT_EQUALITY, bool>
305typename std::enable_if_t<USE_DEFAULT_EQUALITY, bool>
311bool equalAttrArgs(
T *A1_B,
T *A1_E,
T *A2_B,
T *A2_E,
313 if (A1_E - A1_B != A2_E - A2_B)
316 for (; A1_B != A1_E; ++A1_B, ++A2_B)
317 if (!equalAttrArgs(*A1_B, *A2_B, Context))
324bool equalAttrArgs<Attr *>(
Attr *A1,
Attr *A2,
330bool equalAttrArgs<Expr *>(
Expr *A1,
Expr *A2,
342bool equalAttrArgs<const IdentifierInfo *>(
348bool areAlignedAttrsEqual(
const AlignedAttr &A1,
const AlignedAttr &A2,
350 if (A1.getSpelling() != A2.getSpelling())
353 if (A1.isAlignmentExpr() != A2.isAlignmentExpr())
356 if (A1.isAlignmentExpr())
357 return equalAttrArgs(A1.getAlignmentExpr(), A2.getAlignmentExpr(), Context);
359 return equalAttrArgs(A1.getAlignmentType()->getType(),
360 A2.getAlignmentType()->getType(), Context);
364#include "clang/AST/AttrImpl.inc"
Defines the clang::ASTContext interface.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
unsigned getTargetDefaultAlignForAttributeAligned() const
Return the default alignment for attribute((aligned)) on this target, to be used if no alignment valu...
uint64_t getCharWidth() const
Return the size of the character type, in bits.
Attr - This represents one attribute.
bool isEquivalent(const Attr &Other, StructuralEquivalenceContext &Context) const
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
Decl - This represents one declaration (or definition), e.g.
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
This represents one expression.
One of these records is kept for each identifier that is lexed.
A (possibly-)qualified type.
StringLiteral - This represents a string literal expression, e.g.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
bool isEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
Determine structural equivalence of two types.
@ OS
Indicates that the tracking object is a descendant of a referenced-counted OSObject,...
The JSON file list parser is used to communicate input to InstallAPI.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
const FunctionProtoType * T
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ConceptReference *C)
Insertion operator for diagnostics.
U cast(CodeGen::Address addr)
Describes how types, statements, expressions, and declarations should be printed.