summaryrefslogtreecommitdiff
path: root/compilerplugins
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2014-06-17 10:41:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-06-17 15:51:53 +0200
commit6fcc7efad066d6f3804196f3d3fbddd6a0a485cb (patch)
tree146da181eec205c25e51c8a0444c45732db042d2 /compilerplugins
parentf66eec462348513932fa96ec74c29b054bd05a07 (diff)
Fix logic to obtain callee's FunctionProtoType (if any)
Change-Id: I1bfdd865429cc6fa89ea3b6b4fc132b5d5b57b0d
Diffstat (limited to 'compilerplugins')
-rw-r--r--compilerplugins/clang/implicitboolconversion.cxx17
1 files changed, 11 insertions, 6 deletions
diff --git a/compilerplugins/clang/implicitboolconversion.cxx b/compilerplugins/clang/implicitboolconversion.cxx
index 6503ca8d2860..d8ef00e6dbef 100644
--- a/compilerplugins/clang/implicitboolconversion.cxx
+++ b/compilerplugins/clang/implicitboolconversion.cxx
@@ -170,17 +170,22 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
FunctionDecl const * fd = dyn_cast<FunctionDecl>(d);
if (fd != nullptr && fd->isExternC()) {
ext = true;
- PointerType const * pt = dyn_cast<PointerType>(fd->getType());
- t = (pt == nullptr ? fd->getType() : pt->getPointeeType())
- ->getAs<FunctionProtoType>();
+ PointerType const * pt = fd->getType()->getAs<PointerType>();
+ QualType t2(pt == nullptr ? fd->getType() : pt->getPointeeType());
+ t = t2->getAs<FunctionProtoType>();
+ assert(
+ t != nullptr || !compiler.getLangOpts().CPlusPlus
+ || (fd->getBuiltinID() != Builtin::NotBuiltin
+ && isa<FunctionNoProtoType>(t2)));
+ // __builtin_*s have no proto type?
} else {
VarDecl const * vd = dyn_cast<VarDecl>(d);
if (vd != nullptr && vd->isExternC())
{
ext = true;
- PointerType const * pt = dyn_cast<PointerType>(vd->getType());
+ PointerType const * pt = vd->getType()->getAs<PointerType>();
t = (pt == nullptr ? vd->getType() : pt->getPointeeType())
- ->getAs<FunctionProtoType>();
+ ->castAs<FunctionProtoType>();
}
}
}
@@ -192,7 +197,7 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
[&i](Expr * e) { return i == e->IgnoreParens(); });
if (j == expr->arg_end()) {
reportWarning(i);
- } else {
+ } else if (t != nullptr) {
std::ptrdiff_t n = j - expr->arg_begin();
assert(n >= 0);
assert(