diff options
author | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-12-10 18:15:53 +0000 |
---|---|---|
committer | Philip Withnall <philip.withnall@collabora.co.uk> | 2013-12-10 18:15:53 +0000 |
commit | f9cadd02d1a825a4b5dae0f5a0059798af49e0c0 (patch) | |
tree | e13b337a7a1bf09b8925c9dbfc208e2cb015b0c7 /clang-plugin | |
parent | 565e8507498cc940c2c64230db6c538435443a25 (diff) |
clang-plugin: Various improvements to debug output
Diffstat (limited to 'clang-plugin')
-rw-r--r-- | clang-plugin/assertion-extracter.cpp | 3 | ||||
-rw-r--r-- | clang-plugin/gassert-attributes.cpp | 2 | ||||
-rw-r--r-- | clang-plugin/gir-manager.cpp | 7 | ||||
-rw-r--r-- | clang-plugin/nullability-checker.cpp | 13 |
4 files changed, 16 insertions, 9 deletions
diff --git a/clang-plugin/assertion-extracter.cpp b/clang-plugin/assertion-extracter.cpp index ac033e0..6cac6c9 100644 --- a/clang-plugin/assertion-extracter.cpp +++ b/clang-plugin/assertion-extracter.cpp @@ -741,6 +741,7 @@ _assertion_is_explicit_nonnull_check (Expr& assertion_expr, Expr::NullPointerConstantValueDependence::NPC_ValueDependentIsNotNull); if (k != Expr::NullPointerConstantKind::NPCK_NotNull && bin_expr.getLHS ()->IgnoreParenCasts ()->getStmtClass () == Expr::DeclRefExprClass) { + DEBUG ("Found non-NULL check."); ret.insert (cast<DeclRefExpr> (bin_expr.getLHS ()->IgnoreParenCasts ())->getDecl ()); return 1; } @@ -775,6 +776,7 @@ _assertion_is_explicit_nonnull_check (Expr& assertion_expr, Expr* sub_expr = cast_expr.getSubExpr ()->IgnoreParenCasts (); if (sub_expr->getStmtClass () == Expr::DeclRefExprClass) { + DEBUG ("Found non-NULL check."); ret.insert (cast<DeclRefExpr> (sub_expr)->getDecl ()); return 1; } @@ -786,6 +788,7 @@ _assertion_is_explicit_nonnull_check (Expr& assertion_expr, case Expr::DeclRefExprClass: { /* A variable reference, which will implicitly become a non-NULL * check. */ + DEBUG ("Found non-NULL check."); DeclRefExpr& decl_ref_expr = cast<DeclRefExpr> (assertion_expr); ret.insert (decl_ref_expr.getDecl ()); return 1; diff --git a/clang-plugin/gassert-attributes.cpp b/clang-plugin/gassert-attributes.cpp index a200481..8adaaae 100644 --- a/clang-plugin/gassert-attributes.cpp +++ b/clang-plugin/gassert-attributes.cpp @@ -49,7 +49,7 @@ static void _handle_assertion (FunctionDecl& func, Expr& assertion_expr, const ASTContext& context) { - DEBUG ("Handling assertion."); + DEBUG_EXPR ("Handling assertion: ", assertion_expr); /* If the assertion is a non-NULL check, add nonnull attributes to the * function’s parameters accordingly. */ diff --git a/clang-plugin/gir-manager.cpp b/clang-plugin/gir-manager.cpp index 9025b4a..4dcfcb4 100644 --- a/clang-plugin/gir-manager.cpp +++ b/clang-plugin/gir-manager.cpp @@ -76,10 +76,6 @@ GirManager::find_function_info (const std::string& func_name) const ie = this->_typelibs.end (); it != ie; ++it) { const Nspace r = *it; - DEBUG ("Looking for function " << func_name << - " in repository " << r.nspace << " (version " << - r.version << ", C prefix ‘" << r.c_prefix << "’)."); - /* The func_name includes the namespace, which needs stripping. * e.g. g_irepository_find_by_name → find_by_name. */ if (func_name.compare (0, r.c_prefix.size (), @@ -88,8 +84,6 @@ GirManager::find_function_info (const std::string& func_name) const r.c_prefix.size () + 1 /* underscore */; func_name_stripped = func_name.substr (prefix_len); } else { - DEBUG ("\tDoesn’t match C prefix ‘" << r.c_prefix << - "’."); continue; } @@ -99,7 +93,6 @@ GirManager::find_function_info (const std::string& func_name) const if (info != NULL) { /* Successfully found an entry in the typelib. */ - DEBUG ("Found info!"); break; } } diff --git a/clang-plugin/nullability-checker.cpp b/clang-plugin/nullability-checker.cpp index 5cf3f17..e381bb2 100644 --- a/clang-plugin/nullability-checker.cpp +++ b/clang-plugin/nullability-checker.cpp @@ -87,10 +87,22 @@ NullabilityVisitor::TraverseFunctionDecl (FunctionDecl* func) return true; } + DEBUG ("Examining " << func->getNameAsString ()); + /* For each parameter, check whether it has an (allow-none) annotation, * a nonnull attribute, and a non-NULL assertion. */ NonNullAttr* nonnull_attr = func->getAttr<NonNullAttr> (); + if (nonnull_attr != NULL) { + DEBUG ("nonnull attribute indices:"); + for (NonNullAttr::args_iterator it = nonnull_attr->args_begin (), + ie = nonnull_attr->args_end (); it != ie; ++it) { + DEBUG ("\t" << *it); + } + } else { + DEBUG ("No nonnull attribute."); + } + /* Try to find typelib information about the function. */ std::string func_name = func->getNameAsString (); /* TODO: expensive? */ GIBaseInfo* info = @@ -108,7 +120,6 @@ NullabilityVisitor::TraverseFunctionDecl (FunctionDecl* func) } /* Parse the function’s body for assertions. */ - DEBUG ("Examining " << func->getNameAsString ()); std::unordered_set<const ValueDecl*> asserted_parms; ASTContext& context = func->getASTContext (); |