Bug 1326289 - Fix BitWidth assertion failure in debug clang-plugin, r=ehsan

MozReview-Commit-ID: JNPc4CqEgPd
This commit is contained in:
Michael Layzell 2017-01-18 14:23:25 -05:00
parent d622591233
commit fb045a0ce3
2 changed files with 10 additions and 2 deletions

View File

@ -100,8 +100,12 @@ void OverrideBaseCallChecker::check(
// If list is not empty pop up errors
for (auto BaseMethod : MethodsList) {
std::string QualName;
llvm::raw_string_ostream OS(QualName);
BaseMethod->printQualifiedName(OS);
diag(Method->getLocation(), Error, DiagnosticIDs::Error)
<< BaseMethod->getQualifiedNameAsString()
<< OS.str()
<< Decl->getName();
}
}

View File

@ -65,7 +65,11 @@ void SprintfLiteralChecker::check(
Literal = Result.Nodes.getNodeAs<IntegerLiteral>("constant");
}
if (Type->getSize().ule(Literal->getValue())) {
// We're going to assume here that the bitwidth of both of these values fits within 64 bits.
// and zero-extend both values to 64-bits before comparing them.
uint64_t Size = Type->getSize().getZExtValue();
uint64_t Lit = Literal->getValue().getZExtValue();
if (Size <= Lit) {
diag(D->getLocStart(), Error, DiagnosticIDs::Error) << Name << Replacement;
diag(D->getLocStart(), Note, DiagnosticIDs::Note) << Name;
}