[clang] 5b38292 - [NFC] Use range based loop.
Jun Zhang via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 30 07:45:02 PDT 2022
Author: Jun Zhang
Date: 2022-03-30T22:44:34+08:00
New Revision: 5b38292d5d776439b54e7cc02c7a20c58717f3d2
URL: https://github.com/llvm/llvm-project/commit/5b38292d5d776439b54e7cc02c7a20c58717f3d2
DIFF: https://github.com/llvm/llvm-project/commit/5b38292d5d776439b54e7cc02c7a20c58717f3d2.diff
LOG: [NFC] Use range based loop.
Signed-off-by: Jun Zhang <jun at junz.org>
Differential Revision: https://reviews.llvm.org/D122657
Added:
Modified:
clang/lib/AST/ASTDiagnostic.cpp
Removed:
################################################################################
diff --git a/clang/lib/AST/ASTDiagnostic.cpp b/clang/lib/AST/ASTDiagnostic.cpp
index 0c27c0d14519d..28269ec219e4c 100644
--- a/clang/lib/AST/ASTDiagnostic.cpp
+++ b/clang/lib/AST/ASTDiagnostic.cpp
@@ -270,9 +270,9 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
std::string S = Ty.getAsString(Context.getPrintingPolicy());
std::string CanS = CanTy.getAsString(Context.getPrintingPolicy());
- for (unsigned I = 0, E = QualTypeVals.size(); I != E; ++I) {
+ for (const intptr_t &QualTypeVal : QualTypeVals) {
QualType CompareTy =
- QualType::getFromOpaquePtr(reinterpret_cast<void*>(QualTypeVals[I]));
+ QualType::getFromOpaquePtr(reinterpret_cast<void *>(QualTypeVal));
if (CompareTy.isNull())
continue;
if (CompareTy == Ty)
@@ -302,11 +302,11 @@ ConvertTypeToDiagnosticString(ASTContext &Context, QualType Ty,
// Check to see if we already desugared this type in this
// diagnostic. If so, don't do it again.
bool Repeated = false;
- for (unsigned i = 0, e = PrevArgs.size(); i != e; ++i) {
+ for (const auto &PrevArg : PrevArgs) {
// TODO: Handle ak_declcontext case.
- if (PrevArgs[i].first == DiagnosticsEngine::ak_qualtype) {
- void *Ptr = (void*)PrevArgs[i].second;
- QualType PrevTy(QualType::getFromOpaquePtr(Ptr));
+ if (PrevArg.first == DiagnosticsEngine::ak_qualtype) {
+ QualType PrevTy(
+ QualType::getFromOpaquePtr(reinterpret_cast<void *>(PrevArg.second)));
if (PrevTy == Ty) {
Repeated = true;
break;
More information about the cfe-commits
mailing list