Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions clang-tools-extra/clang-tidy/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Checks: >
cppcoreguidelines-missing-std-forward,
cppcoreguidelines-rvalue-reference-param-not-moved,
cppcoreguidelines-virtual-class-destructor,
google-readability-casting,
misc-const-correctness,
modernize-*,
-modernize-avoid-c-arrays,
Expand Down
3 changes: 2 additions & 1 deletion clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,8 @@ void ClangTidyDiagnosticConsumer::forwardDiagnostic(const Diagnostic &Info) {
Builder << Qualifiers::fromOpaqueValue(Info.getRawArg(Index));
break;
case clang::DiagnosticsEngine::ak_qualtype:
Builder << QualType::getFromOpaquePtr((void *)Info.getRawArg(Index));
Builder << QualType::getFromOpaquePtr(
reinterpret_cast<void *>(Info.getRawArg(Index)));
break;
case clang::DiagnosticsEngine::ak_declarationname:
Builder << DeclarationName::getFromOpaqueInteger(Info.getRawArg(Index));
Expand Down
15 changes: 6 additions & 9 deletions clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
const QualType StructFieldTy = StructField->getType();
if (StructFieldTy->isIncompleteType())
return;
const unsigned int StructFieldWidth =
(unsigned int)Result.Context->getTypeInfo(StructFieldTy.getTypePtr())
.Width;
const unsigned int StructFieldWidth = static_cast<unsigned int>(
Result.Context->getTypeInfo(StructFieldTy.getTypePtr()).Width);
FieldSizes.emplace_back(StructFieldWidth, StructField->getFieldIndex());
// FIXME: Recommend a reorganization of the struct (sort by StructField
// size, largest to smallest).
Expand All @@ -79,7 +78,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
CharUnits::fromQuantity(std::max<clang::CharUnits::QuantityType>(
std::ceil(static_cast<float>(TotalBitSize) / CharSize), 1));
const CharUnits MaxAlign = CharUnits::fromQuantity(
std::ceil((float)Struct->getMaxAlignment() / CharSize));
std::ceil(static_cast<float>(Struct->getMaxAlignment()) / CharSize));
const CharUnits CurrAlign =
Result.Context->getASTRecordLayout(Struct).getAlignment();
const CharUnits NewAlign = computeRecommendedAlignment(MinByteSize);
Expand All @@ -99,8 +98,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
diag(Struct->getLocation(),
"accessing fields in struct %0 is inefficient due to padding; only "
"needs %1 bytes but is using %2 bytes")
<< Struct << (int)MinByteSize.getQuantity()
<< (int)CurrSize.getQuantity()
<< Struct << MinByteSize.getQuantity() << CurrSize.getQuantity()
<< FixItHint::CreateInsertion(Struct->getEndLoc().getLocWithOffset(1),
" __attribute__((packed))");
diag(Struct->getLocation(),
Expand All @@ -112,8 +110,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {

FixItHint FixIt;
auto *Attribute = Struct->getAttr<AlignedAttr>();
const std::string NewAlignQuantity =
std::to_string((int)NewAlign.getQuantity());
const std::string NewAlignQuantity = std::to_string(NewAlign.getQuantity());
if (Attribute) {
FixIt = FixItHint::CreateReplacement(
Attribute->getRange(),
Expand All @@ -130,7 +127,7 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
diag(Struct->getLocation(),
"accessing fields in struct %0 is inefficient due to poor alignment; "
"currently aligned to %1 bytes, but recommended alignment is %2 bytes")
<< Struct << (int)CurrAlign.getQuantity() << NewAlignQuantity << FixIt;
<< Struct << CurrAlign.getQuantity() << NewAlignQuantity << FixIt;

diag(Struct->getLocation(),
"use \"__attribute__((aligned(%0)))\" to align struct %1 to %0 bytes",
Expand Down
18 changes: 10 additions & 8 deletions clang-tools-extra/clang-tidy/altera/UnrollLoopsCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,22 @@ bool UnrollLoopsCheck::hasLargeNumIterations(const Stmt *Statement,
return true;
switch (Op->getOpcode()) {
case (BO_AddAssign):
Iterations = std::ceil(float(EndValue - InitValue) / ConstantValue);
Iterations =
std::ceil(static_cast<float>(EndValue - InitValue) / ConstantValue);
break;
case (BO_SubAssign):
Iterations = std::ceil(float(InitValue - EndValue) / ConstantValue);
Iterations =
std::ceil(static_cast<float>(InitValue - EndValue) / ConstantValue);
break;
case (BO_MulAssign):
Iterations =
1 + ((std::log((double)EndValue) - std::log((double)InitValue)) /
std::log((double)ConstantValue));
Iterations = 1 + ((std::log(static_cast<double>(EndValue)) -
std::log(static_cast<double>(InitValue))) /
std::log(static_cast<double>(ConstantValue)));
break;
case (BO_DivAssign):
Iterations =
1 + ((std::log((double)InitValue) - std::log((double)EndValue)) /
std::log((double)ConstantValue));
Iterations = 1 + ((std::log(static_cast<double>(InitValue)) -
std::log(static_cast<double>(EndValue))) /
std::log(static_cast<double>(ConstantValue)));
break;
default:
// All other operators are not handled; assume large bounds.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void SuspiciousMissingCommaCheck::check(

// Warn only when concatenation is not common in this initializer list.
// The current threshold is set to less than 1/5 of the string literals.
if (double(Count) / Size > RatioThreshold)
if (static_cast<double>(Count) / Size > RatioThreshold)
return;

diag(ConcatenatedLiteral->getBeginLoc(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ static llvm::SmallString<64U> skeleton(StringRef Name) {
errs() << "Unicode conversion issue\n";
break;
}
Skeleton.append((char *)BufferStart, (char *)IBuffer);
Skeleton.append(reinterpret_cast<char *>(BufferStart),
reinterpret_cast<char *>(IBuffer));
}
}
return Skeleton;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ static bool containsMisleadingBidi(StringRef Buffer,
}
llvm::UTF32 CodePoint = 0;
const llvm::ConversionResult Result = llvm::convertUTF8Sequence(
(const llvm::UTF8 **)&CurPtr, (const llvm::UTF8 *)Buffer.end(),
&CodePoint, llvm::strictConversion);
reinterpret_cast<const llvm::UTF8 **>(&CurPtr),
reinterpret_cast<const llvm::UTF8 *>(Buffer.end()), &CodePoint,
llvm::strictConversion);

// If conversion fails, utf-8 is designed so that we can just try next char.
if (Result != llvm::conversionOK) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ static bool hasRTLCharacters(StringRef Buffer) {
while (CurPtr < EndPtr) {
llvm::UTF32 CodePoint = 0;
const llvm::ConversionResult Result = llvm::convertUTF8Sequence(
(const llvm::UTF8 **)&CurPtr, (const llvm::UTF8 *)EndPtr, &CodePoint,
reinterpret_cast<const llvm::UTF8 **>(&CurPtr),
reinterpret_cast<const llvm::UTF8 *>(EndPtr), &CodePoint,
llvm::strictConversion);
if (Result != llvm::conversionOK)
break;
Expand Down
5 changes: 3 additions & 2 deletions clang-tools-extra/clang-tidy/openmp/UseDefaultNoneCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ void UseDefaultNoneCheck::check(const MatchFinder::MatchResult &Result) {
"OpenMP directive '%0' specifies 'default(%1)' clause, consider using "
"'default(none)' clause instead")
<< getOpenMPDirectiveName(Directive->getDirectiveKind())
<< getOpenMPSimpleClauseTypeName(Clause->getClauseKind(),
unsigned(Clause->getDefaultKind()));
<< getOpenMPSimpleClauseTypeName(
Clause->getClauseKind(),
llvm::to_underlying(Clause->getDefaultKind()));
diag(Clause->getBeginLoc(), "existing 'default' clause specified here",
DiagnosticIDs::Note);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ void FunctionCognitiveComplexityCheck::check(
// Increase, on the other hand, can be 0.

diag(Detail.Loc, Msgs[MsgId], DiagnosticIDs::Note)
<< (unsigned)Increase << (unsigned)Detail.Nesting << 1 + Detail.Nesting;
<< Increase << Detail.Nesting << 1 + Detail.Nesting;
}
}

Expand Down
Loading