From 22b12a354d144e014387c97e3f8a43e95c4ca4a1 Mon Sep 17 00:00:00 2001 From: ASDAlexander77 Date: Wed, 28 Oct 2026 11:54:18 +0000 Subject: [PATCH] Fix C4018 signed/unsigned comparison warnings Give the loop counters and the bounds check the type of the size they compare against. printDiagnostics keeps a signed counter because its inner loop walks back to index 0 with `>= 0`. Co-Authored-By: Claude Opus 5.5 --- tslang/lib/TypeScript/DiagnosticHelper.cpp | 2 +- tslang/lib/TypeScript/MLIRGenGenerics.cpp | 2 +- tslang/lib/TypeScript/MLIRGenImpl.h | 2 +- tslang/lib/TypeScript/MLIRGenVariables.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tslang/lib/TypeScript/DiagnosticHelper.cpp b/tslang/lib/TypeScript/DiagnosticHelper.cpp index 532091dfa..9b4cf0b59 100644 --- a/tslang/lib/TypeScript/DiagnosticHelper.cpp +++ b/tslang/lib/TypeScript/DiagnosticHelper.cpp @@ -108,7 +108,7 @@ void printLocation(llvm::raw_ostream &os, mlir::Location location, llvm::StringR void printDiagnostics(SourceMgrDiagnosticHandlerEx &sourceMgrHandler, mlir::SmallVector> &postponedMessages, bool disableWarnings) { - for (auto msgIndex = 0; msgIndex < postponedMessages.size(); msgIndex++) + for (int msgIndex = 0; msgIndex < static_cast(postponedMessages.size()); msgIndex++) { auto &diag = postponedMessages[msgIndex]; diff --git a/tslang/lib/TypeScript/MLIRGenGenerics.cpp b/tslang/lib/TypeScript/MLIRGenGenerics.cpp index 0e729e0c1..c2a5c0e1f 100644 --- a/tslang/lib/TypeScript/MLIRGenGenerics.cpp +++ b/tslang/lib/TypeScript/MLIRGenGenerics.cpp @@ -426,7 +426,7 @@ namespace mlirgen return; } - for (auto paramIndex = 0; paramIndex < tempfuncType.size(); paramIndex++) + for (size_t paramIndex = 0; paramIndex < tempfuncType.size(); paramIndex++) { auto currentTemplateType = tempfuncType[paramIndex]; auto currentType = funcType[paramIndex]; diff --git a/tslang/lib/TypeScript/MLIRGenImpl.h b/tslang/lib/TypeScript/MLIRGenImpl.h index 82a3682db..7bb06b73b 100644 --- a/tslang/lib/TypeScript/MLIRGenImpl.h +++ b/tslang/lib/TypeScript/MLIRGenImpl.h @@ -13185,7 +13185,7 @@ class MLIRGenImpl NodeFactory nf(NodeFactoryFlags::None); NodeArray argumentsArray; - for (auto index = 1; index < funcType.getNumInputs(); index++) + for (unsigned index = 1; index < funcType.getNumInputs(); index++) { std::string paramName("p"); paramName += std::to_string(index - 1); diff --git a/tslang/lib/TypeScript/MLIRGenVariables.cpp b/tslang/lib/TypeScript/MLIRGenVariables.cpp index 6074cfe84..a5833d1fb 100644 --- a/tslang/lib/TypeScript/MLIRGenVariables.cpp +++ b/tslang/lib/TypeScript/MLIRGenVariables.cpp @@ -416,7 +416,7 @@ namespace mlirgen } // past the end: the default of the element type, null for a reference (see below) - if (index >= constArrayType.getSize()) + if (static_cast(index) >= constArrayType.getSize()) { return V(builder.create(location, constArrayType.getElementType())); }