20void LoopHintAttr::printPrettyPragma(raw_ostream &OS,
22 unsigned SpellingIndex = getAttributeSpellingListIndex();
25 if (SpellingIndex == Pragma_nounroll ||
26 SpellingIndex == Pragma_nounroll_and_jam)
28 else if (SpellingIndex == Pragma_unroll ||
29 SpellingIndex == Pragma_unroll_and_jam) {
30 OS <<
' ' << getValueString(Policy);
34 assert(SpellingIndex == Pragma_clang_loop &&
"Unexpected spelling");
35 OS <<
' ' << getOptionName(option) << getValueString(Policy);
40std::string LoopHintAttr::getValueString(
const PrintingPolicy &Policy)
const {
41 std::string ValueName;
42 llvm::raw_string_ostream OS(ValueName);
45 value->printPretty(OS,
nullptr, Policy);
46 else if (state == FixedWidth || state == ScalableWidth) {
48 value->printPretty(OS,
nullptr, Policy);
49 if (state == ScalableWidth)
51 }
else if (state == ScalableWidth)
55 }
else if (state == Enable)
57 else if (state == Full)
59 else if (state == AssumeSafety)
60 OS <<
"assume_safety";
69LoopHintAttr::getDiagnosticName(
const PrintingPolicy &Policy)
const {
70 unsigned SpellingIndex = getAttributeSpellingListIndex();
71 if (SpellingIndex == Pragma_nounroll)
72 return "#pragma nounroll";
73 else if (SpellingIndex == Pragma_unroll)
74 return "#pragma unroll" +
75 (option == UnrollCount ? getValueString(Policy) :
"");
76 else if (SpellingIndex == Pragma_nounroll_and_jam)
77 return "#pragma nounroll_and_jam";
78 else if (SpellingIndex == Pragma_unroll_and_jam)
79 return "#pragma unroll_and_jam" +
80 (option == UnrollAndJamCount ? getValueString(Policy) :
"");
82 assert(SpellingIndex == Pragma_clang_loop &&
"Unexpected spelling");
83 return getOptionName(option) + getValueString(Policy);
86void OMPDeclareSimdDeclAttr::printPrettyPragma(
88 if (getBranchState() != BS_Undefined)
89 OS <<
' ' << ConvertBranchStateTyToStr(getBranchState());
90 if (
auto *
E = getSimdlen()) {
95 if (uniforms_size() > 0) {
98 for (
auto *
E : uniforms()) {
105 alignments_iterator NI = alignments_begin();
106 for (
auto *
E : aligneds()) {
111 (*NI)->printPretty(OS,
nullptr, Policy);
116 steps_iterator I = steps_begin();
117 modifiers_iterator MI = modifiers_begin();
118 for (
auto *
E : linears()) {
128 (*I)->printPretty(OS,
nullptr, Policy);
136void OMPDeclareTargetDeclAttr::printPrettyPragma(
139 if (getDevType() != DT_Any)
140 OS <<
" device_type(" << ConvertDevTypeTyToStr(getDevType()) <<
")";
141 if (getMapType() != MT_To && getMapType() != MT_Enter)
142 OS <<
' ' << ConvertMapTypeTyToStr(getMapType());
143 if (
Expr *
E = getIndirectExpr()) {
147 }
else if (getIndirect()) {
152std::optional<OMPDeclareTargetDeclAttr *>
153OMPDeclareTargetDeclAttr::getActiveAttr(
const ValueDecl *VD) {
154 if (llvm::all_of(VD->
redecls(), [](
const Decl *
D) { return !D->hasAttrs(); }))
157 OMPDeclareTargetDeclAttr *FoundAttr =
nullptr;
160 if (Level <= Attr->getLevel()) {
171std::optional<OMPDeclareTargetDeclAttr::MapTypeTy>
172OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(
const ValueDecl *VD) {
173 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
175 return (*ActiveAttr)->getMapType();
179std::optional<OMPDeclareTargetDeclAttr::DevTypeTy>
180OMPDeclareTargetDeclAttr::getDeviceType(
const ValueDecl *VD) {
181 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
183 return (*ActiveAttr)->getDevType();
187std::optional<SourceLocation>
188OMPDeclareTargetDeclAttr::getLocation(
const ValueDecl *VD) {
189 std::optional<OMPDeclareTargetDeclAttr *> ActiveAttr = getActiveAttr(VD);
191 return (*ActiveAttr)->getRange().getBegin();
200void OMPDeclareVariantAttr::printPrettyPragma(
202 if (
const Expr *
E = getVariantFuncRef()) {
207 OS <<
" match(" << traitInfos <<
")";
211 assert(*I &&
"Expected non-null Stmt");
214 (*I)->printPretty(OS,
nullptr, Policy);
217 if (adjustArgsNothing_size()) {
218 OS <<
" adjust_args(nothing:";
219 PrintExprs(adjustArgsNothing_begin(), adjustArgsNothing_end());
222 if (adjustArgsNeedDevicePtr_size()) {
223 OS <<
" adjust_args(need_device_ptr:";
224 PrintExprs(adjustArgsNeedDevicePtr_begin(), adjustArgsNeedDevicePtr_end());
233 OS << getInteropTypeString(I);
237 if (appendArgs_size()) {
238 OS <<
" append_args(";
239 PrintInteropInfo(appendArgs_begin(), appendArgs_end());
244unsigned AlignedAttr::getAlignment(
ASTContext &Ctx)
const {
245 assert(!isAlignmentDependent());
246 if (getCachedAlignmentValue())
247 return *getCachedAlignmentValue();
250 if (!isAlignmentExpr()) {
251 QualType T = getAlignmentType()->getType();
256 T =
T.getNonReferenceType();
258 if (
T.getQualifiers().hasUnaligned())
267 return alignmentExpr->EvaluateKnownConstInt(Ctx).getZExtValue() *
273#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.
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.
Helper data structure representing the traits in a match clause of an declare variant or metadirectiv...
A (possibly-)qualified type.
void printPretty(raw_ostream &OS, PrinterHelper *Helper, const PrintingPolicy &Policy, unsigned Indentation=0, StringRef NewlineSymbol="\n", const ASTContext *Context=nullptr) const
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
The JSON file list parser is used to communicate input to InstallAPI.
const char * getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind, unsigned Type)
const StreamingDiagnostic & operator<<(const StreamingDiagnostic &DB, const ASTContext::SectionInfo &Section)
Insertion operator for diagnostics.
const FunctionProtoType * T
Describes how types, statements, expressions, and declarations should be printed.