Kaydet (Commit) 6fcc7efa authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Fix logic to obtain callee's FunctionProtoType (if any)

Change-Id: I1bfdd865429cc6fa89ea3b6b4fc132b5d5b57b0d
üst f66eec46
...@@ -170,17 +170,22 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) { ...@@ -170,17 +170,22 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
FunctionDecl const * fd = dyn_cast<FunctionDecl>(d); FunctionDecl const * fd = dyn_cast<FunctionDecl>(d);
if (fd != nullptr && fd->isExternC()) { if (fd != nullptr && fd->isExternC()) {
ext = true; ext = true;
PointerType const * pt = dyn_cast<PointerType>(fd->getType()); PointerType const * pt = fd->getType()->getAs<PointerType>();
t = (pt == nullptr ? fd->getType() : pt->getPointeeType()) QualType t2(pt == nullptr ? fd->getType() : pt->getPointeeType());
->getAs<FunctionProtoType>(); t = t2->getAs<FunctionProtoType>();
assert(
t != nullptr || !compiler.getLangOpts().CPlusPlus
|| (fd->getBuiltinID() != Builtin::NotBuiltin
&& isa<FunctionNoProtoType>(t2)));
// __builtin_*s have no proto type?
} else { } else {
VarDecl const * vd = dyn_cast<VarDecl>(d); VarDecl const * vd = dyn_cast<VarDecl>(d);
if (vd != nullptr && vd->isExternC()) if (vd != nullptr && vd->isExternC())
{ {
ext = true; ext = true;
PointerType const * pt = dyn_cast<PointerType>(vd->getType()); PointerType const * pt = vd->getType()->getAs<PointerType>();
t = (pt == nullptr ? vd->getType() : pt->getPointeeType()) t = (pt == nullptr ? vd->getType() : pt->getPointeeType())
->getAs<FunctionProtoType>(); ->castAs<FunctionProtoType>();
} }
} }
} }
...@@ -192,7 +197,7 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) { ...@@ -192,7 +197,7 @@ bool ImplicitBoolConversion::TraverseCallExpr(CallExpr * expr) {
[&i](Expr * e) { return i == e->IgnoreParens(); }); [&i](Expr * e) { return i == e->IgnoreParens(); });
if (j == expr->arg_end()) { if (j == expr->arg_end()) {
reportWarning(i); reportWarning(i);
} else { } else if (t != nullptr) {
std::ptrdiff_t n = j - expr->arg_begin(); std::ptrdiff_t n = j - expr->arg_begin();
assert(n >= 0); assert(n >= 0);
assert( assert(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment