Fix compiler warnings#611
Conversation
There was a problem hiding this comment.
Code Review
This pull request implements a broad set of code cleanups and modernization updates, including transitioning to the latest MLIR casting APIs, removing unused variables, and addressing compiler warnings through explicit casts and [[maybe_unused]] attributes. It also enhances safety by adding llvm_unreachable to incomplete switch blocks and refining sign extension logic. The review feedback identifies opportunities to further clean the code by removing redundant attributes, deleting unused variables rather than suppressing warnings, and using more targeted techniques to handle virtual function hiding.
| // ============================================================================= | ||
|
|
||
| static void printLayout(AsmPrinter &printer, Attribute layoutAttr) { | ||
| [[maybe_unused]] [[maybe_unused]] static void printLayout(AsmPrinter &printer, Attribute layoutAttr) { |
There was a problem hiding this comment.
| auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t"); | ||
| auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t"); | ||
| [[maybe_unused]] auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t"); |
There was a problem hiding this comment.
The variable u64Ty appears to be unused. Instead of suppressing the warning with [[maybe_unused]], it is better to remove the unused variable entirely to keep the code clean.
| auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t"); | |
| auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t"); | |
| [[maybe_unused]] auto u64Ty = emitc::OpaqueType::get(ctx, "uint64_t"); | |
| auto u32Ty = emitc::OpaqueType::get(ctx, "uint32_t"); |
| #pragma GCC diagnostic ignored "-Woverloaded-virtual" | ||
| // https://discourse.llvm.org/t/matchandrewrite-hiding-virtual-functions/84933/8 |
There was a problem hiding this comment.
While suppressing -Woverloaded-virtual file-wide reduces noise, it can hide legitimate issues where a virtual function is unintentionally hidden. As suggested in the linked LLVM discourse thread, a more targeted approach is to add using OpConversionPattern<SourceOp>::matchAndRewrite; (or the appropriate base class) within each pattern class that triggers the warning. This resolves the name hiding while keeping the diagnostic active for the rest of the file.
Codex Review该评论由 review 机器人自动更新。
SummaryPR #611 contains 1 correctness issue in EmitC lowering for SCALING reinterpret-casts. Findings
The new switch case added here folds |
This PR fixes compiler warnings making it easier to fix errors and reducing noise.
Most of the fixes belong to 4 categories
Perhaps is worth considering adding a "error on warning" in the CI.