Skip to content

Commit 3bc9323

Browse files
authored
Merge pull request #84 from rdmarsh2/rdmarsh/cpp/macro-get-expr-conversions
C++: exclude conversion in MacroInvocation.getExpr
2 parents 2481bc7 + 51bfb8d commit 3bc9323

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ class MacroInvocation extends MacroAccess {
178178
*/
179179
Expr getExpr() {
180180
result = getAnExpandedElement() and
181-
not (result.getParent() = getAnExpandedElement())
181+
not (result.getParent() = getAnExpandedElement()) and
182+
not result instanceof Conversion
182183
}
183184

184185
/**

cpp/ql/test/library-tests/preprocessor/macroinvocations/getanaffectedelement.expected

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | 2 | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |
5959
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | 3 | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |
6060
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | 4 | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |
61-
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | (...) | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() getExpr() |
62-
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | (...) | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() getExpr() |
61+
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | (...) | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |
62+
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | (...) | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |
6363
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | ... * ... | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() getExpr() |
6464
| macroinvocations.cpp:123:10:123:19 | MACRO_EXPR | macroinvocations.cpp:123:10:123:19 | ... + ... | getAGeneratedElement() getAnAffectedElement() getAnExpandedElement() |

0 commit comments

Comments
 (0)