Files
codeql/cpp/ql/test/library-tests/preprocessor/macroinvocations/getanaffectedelement.ql
Jonas Jensen 4ef5c9af62 C++: Autoformat everything
Some files that will change in #1736 have been spared.

    ./build -j4 target/jars/qlformat
    find ql/cpp/ql -name "*.ql"  -print0 | xargs -0 target/jars/qlformat --input
    find ql/cpp/ql -name "*.qll" -print0 | xargs -0 target/jars/qlformat --input
    (cd ql && git checkout 'cpp/ql/src/semmle/code/cpp/ir/implementation/**/*SSA*.qll')
    buildutils-internal/scripts/pr-checks/sync-identical-files.py --latest
2019-09-09 11:25:53 +02:00

36 lines
928 B
Plaintext

import cpp
predicate reason(MacroInvocation mi, Element e, string reason) {
mi.getAnAffectedElement() = e and reason = "getAnAffectedElement()"
or
mi.getAnExpandedElement() = e and reason = "getAnExpandedElement()"
or
mi.getAGeneratedElement() = e and reason = "getAGeneratedElement()"
or
mi.getExpr() = e and reason = "getExpr()"
or
mi.getStmt() = e and reason = "getStmt()"
or
mi.getEnclosingFunction() = e and reason = "getEnclosingFunction()"
}
string reasonspart(MacroInvocation mi, Element e) {
reason(mi, e, result)
or
exists(string a, string b |
a = reasonspart(mi, e) and
reason(mi, e, b) and
not a.splitAt(" ") >= b and
result = a + " " + b
)
}
string reasons(MacroInvocation mi, Element e) {
result = reasonspart(mi, e) and
not reasonspart(mi, e).length() > result.length()
}
from MacroInvocation mi, Element e
where reason(mi, e, _)
select mi, e, reasons(mi, e)