summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-06 08:49:12 +0100
committerPhilip Withnall <philip.withnall@collabora.co.uk>2014-05-06 08:49:12 +0100
commited4470002876df2dd34196d009abb24a69aefb17 (patch)
treefc9c91020a44574ea4d82a6642f39bd8f471b743
parent0725949d36796960d8815cd6383f339b88dc9a9c (diff)
clang-plugin: Add extra debug info on internal warnings
Just in case these warnings are hit, it would be useful to know what Stmt/Expr caused them.
-rw-r--r--clang-plugin/assertion-extracter.cpp12
-rw-r--r--clang-plugin/debug.h3
2 files changed, 9 insertions, 6 deletions
diff --git a/clang-plugin/assertion-extracter.cpp b/clang-plugin/assertion-extracter.cpp
index 2866849..f9c488a 100644
--- a/clang-plugin/assertion-extracter.cpp
+++ b/clang-plugin/assertion-extracter.cpp
@@ -455,8 +455,8 @@ AssertionExtracter::is_assertion_stmt (Stmt& stmt, const ASTContext& context)
}
case Stmt::StmtClass::NoStmtClass:
default:
- WARN (__func__ << "() can’t handle statements of type " <<
- stmt.getStmtClassName ());
+ WARN_EXPR (__func__ << "() can’t handle statements of type " <<
+ stmt.getStmtClassName (), stmt);
return NULL;
}
}
@@ -691,8 +691,8 @@ _assertion_is_gobject_type_check (Expr& assertion_expr,
}
case Stmt::StmtClass::NoStmtClass:
default:
- WARN (__func__ << "() can’t handle expressions of type " <<
- assertion_expr.getStmtClassName ());
+ WARN_EXPR (__func__ << "() can’t handle expressions of type " <<
+ assertion_expr.getStmtClassName (), assertion_expr);
return 0;
}
}
@@ -825,8 +825,8 @@ _assertion_is_explicit_nonnull_check (Expr& assertion_expr,
}
case Stmt::StmtClass::NoStmtClass:
default:
- WARN (__func__ << "() can’t handle expressions of type " <<
- assertion_expr.getStmtClassName ());
+ WARN_EXPR (__func__ << "() can’t handle expressions of type " <<
+ assertion_expr.getStmtClassName (), assertion_expr);
return 0;
}
}
diff --git a/clang-plugin/debug.h b/clang-plugin/debug.h
index cca2f19..94ef15b 100644
--- a/clang-plugin/debug.h
+++ b/clang-plugin/debug.h
@@ -42,6 +42,9 @@ namespace Debug {
/* For use with internal errors, such as unexpected precondition failures or
* states reached in the plugin internals. Not for user code warnings. */
#define WARN(M) llvm::errs () << "Warning: " << M << "\n"
+#define WARN_EXPR(M, E) llvm::errs () << "Warrning: " << M; \
+ (E).printPretty (llvm::errs (), NULL, context.getPrintingPolicy ()); \
+ llvm::errs () << "\n"
DiagnosticBuilder emit_report (DiagnosticsEngine::Level level,
const std::string& message,