Skip to content

Commit 52af6d5

Browse files
committed
C++: Fix macro handling after extractor changes
1 parent 0b09c64 commit 52af6d5

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

cpp/ql/lib/semmle/code/cpp/Macro.qll

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,9 @@ class MacroInvocation extends MacroAccess {
154154
* well.
155155
*/
156156
Locatable getAnAffectedElement() {
157-
inmacroexpansion(unresolveElement(result), underlyingElement(this)) or
158-
macrolocationbind(underlyingElement(this), result.getLocation())
157+
inmacroexpansion(unresolveElement(result), underlyingElement(this))
158+
or
159+
macrolocationbind(underlyingElement(this), result.getLocation()) and this != result
159160
}
160161

161162
/**

cpp/ql/test/library-tests/macros/inmacroexpansion/inmacroexpansion.expected

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
| test.cpp:4:1:4:1 | operator= | false |
1515
| test.cpp:4:1:4:1 | operator= | false |
1616
| test.cpp:4:1:4:10 | CLASS_DECL | false |
17-
| test.cpp:4:1:4:10 | S | false |
17+
| test.cpp:4:1:4:10 | S | true |
1818
| test.cpp:4:1:4:10 | declaration | true |
1919
| test.cpp:4:1:4:10 | definition of S | true |
2020
| test.cpp:4:1:4:10 | definition of f | true |
2121
| test.cpp:4:1:4:10 | definition of i | true |
2222
| test.cpp:4:1:4:10 | definition of j | true |
23-
| test.cpp:4:1:4:10 | f | false |
24-
| test.cpp:4:1:4:10 | i | false |
23+
| test.cpp:4:1:4:10 | f | true |
24+
| test.cpp:4:1:4:10 | i | true |
2525
| test.cpp:4:1:4:10 | j | true |
2626
| test.cpp:4:1:4:10 | return ... | true |
2727
| test.cpp:4:1:4:10 | { ... } | true |
@@ -30,7 +30,7 @@
3030
| test.cpp:8:1:8:13 | declaration | true |
3131
| test.cpp:8:1:8:13 | definition of f1 | true |
3232
| test.cpp:8:1:8:13 | definition of k | true |
33-
| test.cpp:8:1:8:13 | f1 | false |
33+
| test.cpp:8:1:8:13 | f1 | true |
3434
| test.cpp:8:1:8:13 | k | true |
3535
| test.cpp:8:1:8:13 | return ... | true |
3636
| test.cpp:8:1:8:13 | { ... } | true |
@@ -68,18 +68,18 @@
6868
| test.cpp:38:1:38:13 | 1 | true |
6969
| test.cpp:38:1:38:13 | ... == ... | true |
7070
| test.cpp:38:1:38:13 | STATIC_ASSERT | false |
71-
| test.cpp:38:1:38:13 | static_assert(..., "") | false |
71+
| test.cpp:38:1:38:13 | static_assert(..., "") | true |
7272
| test.cpp:40:1:40:42 | #define ATTRIBUTE [[nodiscard("reason1")]] | false |
7373
| test.cpp:42:1:42:9 | ATTRIBUTE | false |
74-
| test.cpp:42:1:42:9 | nodiscard | false |
75-
| test.cpp:42:1:42:9 | reason1 | false |
74+
| test.cpp:42:1:42:9 | nodiscard | true |
75+
| test.cpp:42:1:42:9 | reason1 | true |
7676
| test.cpp:42:1:42:9 | reason1 | true |
7777
| test.cpp:43:5:43:6 | declaration of f2 | false |
7878
| test.cpp:43:5:43:6 | f2 | false |
7979
| test.cpp:45:1:45:31 | #define ATTRIBUTE_ARG "reason2" | false |
8080
| test.cpp:47:3:47:11 | nodiscard | false |
8181
| test.cpp:47:13:47:25 | ATTRIBUTE_ARG | false |
82-
| test.cpp:47:13:47:25 | reason2 | false |
82+
| test.cpp:47:13:47:25 | reason2 | true |
8383
| test.cpp:47:13:47:25 | reason2 | true |
8484
| test.cpp:48:5:48:6 | declaration of f3 | false |
8585
| test.cpp:48:5:48:6 | f3 | false |

0 commit comments

Comments
 (0)