diff --git a/ClavaWeaver/resources/clava/test/weaver/PragmaData.lara b/ClavaWeaver/resources/clava/test/weaver/PragmaData.lara index 5d0b1c6b3..4587484e4 100644 --- a/ClavaWeaver/resources/clava/test/weaver/PragmaData.lara +++ b/ClavaWeaver/resources/clava/test/weaver/PragmaData.lara @@ -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 diff --git a/ClavaWeaver/resources/clava/test/weaver/cpp/results/PragmaData.lara.txt b/ClavaWeaver/resources/clava/test/weaver/cpp/results/PragmaData.lara.txt index a384727a2..26e07c668 100644 --- a/ClavaWeaver/resources/clava/test/weaver/cpp/results/PragmaData.lara.txt +++ b/ClavaWeaver/resources/clava/test/weaver/cpp/results/PragmaData.lara.txt @@ -11,4 +11,6 @@ Empty Object: Data before insert: 30 Data after insert: 30 Data before insert: 40 -Data after insert: 40 \ No newline at end of file +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} \ No newline at end of file diff --git a/ClavaWeaver/resources/clava/test/weaver/cpp/src/pragma_data.cpp b/ClavaWeaver/resources/clava/test/weaver/cpp/src/pragma_data.cpp index 7ebe585af..5c56fa229 100644 --- a/ClavaWeaver/resources/clava/test/weaver/cpp/src/pragma_data.cpp +++ b/ClavaWeaver/resources/clava/test/weaver/cpp/src/pragma_data.cpp @@ -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();