Token LoopHintTok;
LoopHintTok.startToken();
LoopHintTok.setKind(tok::annot_pragma_loop_hint);
- LoopHintTok.setLocation(PragmaName.getLocation());
+ LoopHintTok.setLocation(Introducer.Loc);
LoopHintTok.setAnnotationEndLoc(PragmaName.getLocation());
LoopHintTok.setAnnotationValue(static_cast<void *>(Info));
TokenList.push_back(LoopHintTok);
auto TokenArray = std::make_unique<Token[]>(1);
TokenArray[0].startToken();
TokenArray[0].setKind(tok::annot_pragma_loop_hint);
- TokenArray[0].setLocation(PragmaName.getLocation());
+ TokenArray[0].setLocation(Introducer.Loc);
TokenArray[0].setAnnotationEndLoc(PragmaName.getLocation());
TokenArray[0].setAnnotationValue(static_cast<void *>(Info));
PP.EnterTokenStream(std::move(TokenArray), 1,
// Create temporary attribute list.
ParsedAttributesWithRange TempAttrs(AttrFactory);
+ SourceLocation StartLoc = Tok.getLocation();
+
// Get loop hints and consume annotated token.
while (Tok.is(tok::annot_pragma_loop_hint)) {
LoopHint Hint;
Stmts, StmtCtx, TrailingElseLoc, Attrs);
Attrs.takeAllFrom(TempAttrs);
+
+ assert(Attrs.Range.getBegin().isInvalid() &&
+ "start of attribute range already set");
+ Attrs.Range.setBegin(StartLoc);
return S;
}
}\r
}\r
\r
+// CHECK: NamespaceDecl {{.*}} attributed_stmt\r
+namespace attributed_stmt {\r
+ // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from <scratch space>\r
+ // file.\r
+\r
+ #define DO_PRAGMA(x) _Pragma (#x)\r
+\r
+ void f() {\r
+ // CHECK: AttributedStmt {{.*}} <line:[[@LINE-3]]:24, line:[[@LINE+2]]:33>\r
+ DO_PRAGMA (unroll(2))\r
+ for (int i = 0; i < 10; ++i);\r
+\r
+ // CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+3]]:33>\r
+ // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:13, col:22>\r
+ #pragma unroll(2)\r
+ for (int i = 0; i < 10; ++i);\r
+\r
+ // CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+5]]:33>\r
+ // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:41>\r
+ #pragma clang loop vectorize(enable)\r
+ // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:42>\r
+ #pragma clang loop interleave(enable)\r
+ for (int i = 0; i < 10; ++i);\r
+\r
+ // CHECK: AttributedStmt {{.*}} <line:[[@LINE+1]]:5, line:[[@LINE+2]]:33>\r
+ _Pragma("unroll(2)")\r
+ for (int i = 0; i < 10; ++i);\r
+ }\r
+}\r
+\r
#if __cplusplus >= 201703L\r
// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list\r
std::map<int, int> construct_with_init_list() {\r