Skip to content

Commit b32e07f

Browse files
committed
fixed forrangelooptest
1 parent 466b163 commit b32e07f

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ def warn_pragma_cilk_grainsize_equals: Warning<
14001400
"'#pragma cilk grainsize' no longer requires '='">,
14011401
InGroup<SourceUsesCilkPlus>;
14021402
def warn_cilk_for_forrange_loop_experimental: Warning<
1403-
"'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!">,
1403+
"'cilk_for' support for for-range loops is currently EXPERIMENTAL only!">,
14041404
InGroup<SourceUsesCilkPlus>;
14051405
def error_hyperobject_arguments: Error<
14061406
"hyperobject must have 0 or 2 callbacks">;

clang/lib/CodeGen/CGCilk.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,10 @@ CodeGenFunction::EmitCilkForRangeStmt(const CilkForRangeStmt &S,
533533
JumpDest Continue = getJumpDestInCurrentScope("pfor.cond");
534534
llvm::BasicBlock *CondBlock = Continue.getBlock();
535535

536-
// TODO: need to check condition and then get to pfor.end
537536
llvm::BasicBlock *InitialEntryBlock = createBasicBlock("pfor.initial.entry");
538537
EmitBlock(InitialEntryBlock);
539538
llvm::Value *InitialBoolCondVal = EvaluateExprAsBool(S.getCond());
540-
// llvm::MDNode *Weights =
541-
// createProfileWeightsForLoop(S.getCond(), getProfileCount(S.getBody()));
542539

543-
// Do we need weights?
544540
Builder.CreateCondBr(InitialBoolCondVal, Continue.getBlock(), LoopExit.getBlock());
545541

546542

clang/lib/Sema/SemaStmtAttr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static Attr *handleLoopHintAttr(Sema &S, Stmt *St, const ParsedAttr &A,
9898
// This could be handled automatically by adding a Subjects definition in
9999
// Attr.td, but that would make the diagnostic behavior worse in this case
100100
// because the user spells this attribute as a pragma.
101-
if (!isa<DoStmt, ForStmt, CXXForRangeStmt, WhileStmt, CilkForStmt>(St)) {
101+
if (!isa<DoStmt, ForStmt, CXXForRangeStmt, WhileStmt, CilkForStmt, CilkForRangeStmt>(St)) {
102102
std::string Pragma = "#pragma " + std::string(PragmaName);
103103
S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << Pragma;
104104
return nullptr;

clang/test/Cilk/rangelooptest.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,40 +53,42 @@ int Cilk_for_range_tests(int n) {
5353
for (int i = 0; i < n; i++)
5454
v[i] = i;
5555

56-
_Cilk_for(auto x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{Cilk for loop has empty body}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
57-
_Cilk_for(auto &x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{Cilk for loop has empty body}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
58-
_Cilk_for(int x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{Cilk for loop has empty body}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
59-
_Cilk_for(StdMock::Empty x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{Cilk for loop has empty body}} expected-error {{no viable conversion from 'int' to 'StdMock::Empty'}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
56+
_Cilk_for(auto x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{'cilk_for' loop has empty body}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
57+
_Cilk_for(auto &x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{'cilk_for' loop has empty body}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
58+
_Cilk_for(int x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{'cilk_for' loop has empty body}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
59+
_Cilk_for(StdMock::Empty x : v); // expected-warning {{range-based for loop has empty body}} expected-warning {{'cilk_for' loop has empty body}} expected-error {{no viable conversion from 'int' to 'StdMock::Empty'}} expected-error {{no viable conversion from 'int' to 'StdMock::Empty'}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
60+
// in line above, the "no viable conversion" error comes twice because of the new CodeGen structure of cilk_for_range loops, which now adds an extra check to the initial condition before entering the loop ("pfor.initial.entry")
61+
6062

6163
// Pairs are aggregate types, which initially had a bug. Assert that they work
6264
StdMock::Vector<StdMock::Pair<int, int>> vp(n);
6365
for (int i = 0; i < n; i++) {
6466
vp[i] = {i, i + 1};
6567
}
66-
_Cilk_for(auto p : vp) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
68+
_Cilk_for(auto p : vp) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
6769
continue;
68-
_Cilk_for(auto &p : vp) { // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
70+
_Cilk_for(auto &p : vp) { // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
6971
continue;
7072
}
7173

7274
int a[5];
73-
_Cilk_for(int x : a) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
75+
_Cilk_for(int x : a) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
7476
continue;
7577

7678
StdMock::Set<int> s(n);
77-
_Cilk_for(int x : s); // expected-error {{Cannot determine length with '__end - __begin'. Please use a random access iterator.}} expected-error {{invalid operands to binary expression ('StdMock::Set<int>::It' and 'StdMock::Set<int>::It')}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
79+
_Cilk_for(int x : s); // expected-error {{Cannot determine length with '__end - __begin'. Please use a random access iterator.}} expected-error {{invalid operands to binary expression ('It' and 'It')}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
7880

7981
// Check for return statements, which cannot appear anywhere in the body of a
8082
// _Cilk_for loop.
81-
_Cilk_for(int i : v) return 7; // expected-error{{cannot return}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
82-
_Cilk_for(int i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
83+
_Cilk_for(int i : v) return 7; // expected-error{{cannot return}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
84+
_Cilk_for(int i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
8385
for (int j = 1; j < i; ++j)
8486
return 7; // expected-error{{cannot return}}
8587

8688
// Check for illegal break statements, which cannot bind to the scope of a
8789
// _Cilk_for loop, but can bind to loops nested within.
88-
_Cilk_for(int i : v) break; // expected-error{{cannot break}} expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
89-
_Cilk_for(int i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
90+
_Cilk_for(int i : v) break; // expected-error{{cannot break}} expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
91+
_Cilk_for(int i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
9092
for (int j = 1; j < i; ++j)
9193
break;
9294

@@ -99,19 +101,19 @@ int range_pragma_tests(int n) {
99101
v[i] = i;
100102

101103
#pragma clang loop unroll_count(4)
102-
_Cilk_for(auto i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
104+
_Cilk_for(auto i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
103105
foo(i);
104106

105107
#pragma cilk grainsize(4)
106-
_Cilk_for(int i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
108+
_Cilk_for(int i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
107109
foo(i);
108110

109111
#pragma cilk grainsize 4
110-
_Cilk_for(auto i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
112+
_Cilk_for(auto i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
111113
foo(i);
112114

113115
#pragma cilk grainsize = 4 // expected-warning{{'#pragma cilk grainsize' no longer requires '='}}
114-
_Cilk_for(int i : v) // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
116+
_Cilk_for(int i : v) // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
115117
foo(i);
116118

117119
return 0;
@@ -122,7 +124,7 @@ int range_scope_tests(int n) {
122124
for (int i = 0; i < n; i++)
123125
v[i] = i;
124126
int A[5];
125-
_Cilk_for(int i : v) { // expected-warning {{'_Cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
127+
_Cilk_for(int i : v) { // expected-warning {{'cilk_for' support for for-range loops is currently EXPERIMENTAL only!}}
126128
int A[5];
127129
A[i % 5] = i;
128130
}

0 commit comments

Comments
 (0)