diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-12-10 18:19:41 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-12-10 18:19:41 +0000 |
commit | 96131573755d84ccba878b4fb93bae75b0156ec9 (patch) | |
tree | d5bc1a13028447571c138b2f8575203550a9deab /clang-plugin/nullability-checker.cpp | |
parent | d6ffc0e559a1c53e235a75010f2b5e5ba9019fff (diff) |
clang-plugin: Add various safety checks for GI base info
There are several situations where the GIR metadata doesn’t match the
Clang AST, so add checks for them to avoid raising spurious warnings and
errors.
• If a function can throw an error, the number of GI callable args is
one fewer than expected (missing a GError argument).
• If a function was shadowed in the GI file, the GIBaseInfo is
retrieved using the shadowed C symbol name, but has the callable
information for the shadowing C symbol, which commonly has more
formal parameters.
• Nullability can only be checked on the copy of a function which
contains its definition, not on every copy (even if the body has
already been parsed).
Diffstat (limited to 'clang-plugin/nullability-checker.cpp')
-rw-r--r-- | clang-plugin/nullability-checker.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/clang-plugin/nullability-checker.cpp b/clang-plugin/nullability-checker.cpp index e381bb2..2e27def 100644 --- a/clang-plugin/nullability-checker.cpp +++ b/clang-plugin/nullability-checker.cpp @@ -75,7 +75,7 @@ NullabilityVisitor::TraverseFunctionDecl (FunctionDecl* func) /* Can only handle functions which have a body defined. */ Stmt* func_body = func->getBody (); - if (func_body == NULL) + if (func_body == NULL || !func->isThisDeclarationADefinition ()) return true; /* The body should be a compound statement, e.g. |