Skip to content

Commit

Permalink
[ClavaWeaver] Updates weaver test 'PragmaData' (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
joaobispo committed Oct 22, 2021
1 parent 874e14d commit b4eae32
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
12 changes: 12 additions & 0 deletions ClavaWeaver/resources/clava/test/weaver/PragmaData.lara
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,16 @@ aspectdef PragmaData
$loopWithPragma2.insertBefore("int global_a;");
println("Data after insert: " + $loopWithPragma2.data.a);

// Setting data without pragma creates a pragma
var $loopWithoutPragma = Query.search("function", "insertWithoutPragma").first();
$loopWithoutPragma.data.a = 42;
$loopWithoutPragma.data.b = 43;
println("Loop without pragma after setting data: " + $loopWithoutPragma.pragmas.map(p => p.code));

// Setting already existing data updates pragma
var $loopWithUpdatedPragma = Query.search("function", "updatePragma").first();
$loopWithUpdatedPragma.data.a = 200;
println("Loop with updated pragma: " + $loopWithUpdatedPragma.pragmas.map(p => p.code));

//from nothing adds pragma; changes reflected in pragma; push/pop preserve; rebuild preserves for ones with pragma
end
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ Empty Object:
Data before insert: 30
Data after insert: 30
Data before insert: 40
Data after insert: 40
Data after insert: 40
Loop without pragma after setting data: #pragma clava data {"a":42,"b":43}
Loop with updated pragma: #pragma clava data {"a":200}
15 changes: 15 additions & 0 deletions ClavaWeaver/resources/clava/test/weaver/cpp/src/pragma_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,21 @@ void insertPreservesPragma2() {

}

void insertWithoutPragma() {
for(int i=0; i<0; i++) {

}
}

void updatePragma() {

#pragma clava data a:100
for(int i=0; i<0; i++) {

}
}


int main() {

foo();
Expand Down

0 comments on commit b4eae32

Please sign in to comment.