Repository: llvm/circt

Issue #3943: Resolve `-Wctad-maybe-unsupported` warnings
Created: 2022-09-19T22:51:56Z
These show up in our CI as well as in local builds, for example:
 /__w/circt/circt/tools/circt-reduce/Reduction.cpp:78:21: warning: 'Optional' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  return moduleOp ? llvm::Optional(moduleOp)
                    ^
/__w/circt/circt/llvm/llvm/include/llvm/ADT/APInt.h:33:29: note: add a deduction guide to suppress this warning
template <typename T> class Optional;
                            ^

Duplicate issue #4133: Clang warnings in fresh compile
Created: 2022-10-19T21:39:04Z
/home/jodemme/circt/lib/Dialect/Comb/CombFolds.cpp:117:10: warning: 'ComplementMatcher' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  return ComplementMatcher(subExpr);
         ^
/home/jodemme/circt/lib/Dialect/Comb/CombFolds.cpp:770:27: note: in instantiation of function template specialization 'm_Complement<mlir::detail::AnyCapturedValueMatcher>' requested here
    if (matchPattern(arg, m_Complement(m_Any(&subExpr)))) {
                          ^
/home/jodemme/circt/lib/Dialect/Comb/CombFolds.cpp:105:8: note: add a deduction guide to suppress this warning
struct ComplementMatcher {
       ^
1 warning generated.
[2385/3241] Building CXX object tools/circt/unittests/Dialect/Moore/CMakeFiles/CIRCTMooreTests.dir/TypesTest.cpp.o
In file included from /home/jodemme/circt/unittests/Dialect/Moore/TypesTest.cpp:11:
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1526:11: warning: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Wsign-compare]
  if (lhs == rhs) {
      ~~~ ^  ~~~
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1553:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
           ^
/home/jodemme/circt/unittests/Dialect/Moore/TypesTest.cpp:185:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
  ASSERT_EQ(arrayType2.getSize(), 42);
  ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2056:32: note: expanded from macro 'ASSERT_EQ'
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                               ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2040:54: note: expanded from macro 'GTEST_ASSERT_EQ'
  ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
                                                     ^
1 warning generated.
[2386/3241] Building CXX object tools/circt/unittests/Dialect/HW/CMakeFiles/CIRCTHWTests.dir/HWModuleTest.cpp.o
In file included from /home/jodemme/circt/unittests/Dialect/HW/HWModuleTest.cpp:14:
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1526:11: warning: comparison of integers of different signs: 'const unsigned long' and 'const int' [-Wsign-compare]
  if (lhs == rhs) {
      ~~~ ^  ~~~
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1553:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned long, int>' requested here
    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
           ^
/home/jodemme/circt/unittests/Dialect/HW/HWModuleTest.cpp:51:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned long, int, nullptr>' requested here
  ASSERT_EQ(ports.size(), 4);
  ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2056:32: note: expanded from macro 'ASSERT_EQ'
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                               ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2040:54: note: expanded from macro 'GTEST_ASSERT_EQ'
  ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
                                                     ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1526:11: warning: comparison of integers of different signs: 'const unsigned int' and 'const int' [-Wsign-compare]
  if (lhs == rhs) {
      ~~~ ^  ~~~
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:1553:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<unsigned int, int>' requested here
    return CmpHelperEQ(lhs_expression, rhs_expression, lhs, rhs);
           ^
/home/jodemme/circt/unittests/Dialect/HW/HWModuleTest.cpp:70:3: note: in instantiation of function template specialization 'testing::internal::EqHelper::Compare<unsigned int, int, nullptr>' requested here
  ASSERT_EQ(output->getNumOperands(), 4);
  ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2056:32: note: expanded from macro 'ASSERT_EQ'
# define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
                               ^
/home/jodemme/circt/llvm/llvm/utils/unittest/googletest/include/gtest/gtest.h:2040:54: note: expanded from macro 'GTEST_ASSERT_EQ'
  ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
                                                     ^
2 warnings generated.
[2811/3241] Building CXX object tools/circt/lib/Dialect/FIRRTL/Import/CMakeFiles/obj.CIRCTImportFIRFile.dir/FIRParser.cpp.o
/home/jodemme/circt/lib/Dialect/FIRRTL/Import/FIRParser.cpp:1243:30: warning: 'SmallVector' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
    builder.create<AttachOp>(SmallVector{dst, src});
                             ^
/home/jodemme/circt/llvm/llvm/../mlir/include/mlir/Support/LLVM.h:72:7: note: add a deduction guide to suppress this warning
class SmallVector;
      ^
1 warning generated.
[2820/3241] Building CXX object tools/circt/tools/circt-reduce/CMakeFiles/circt-reduce.dir/Reduction.cpp.o
/home/jodemme/circt/tools/circt-reduce/Reduction.cpp:78:21: warning: 'Optional' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  return moduleOp ? llvm::Optional(moduleOp)
                    ^
/home/jodemme/circt/llvm/llvm/include/llvm/ADT/APInt.h:34:29: note: add a deduction guide to suppress this warning
template <typename T> class Optional;
                            ^
1 warning generated.
[2931/3241] Building CXX object tools/circt/lib/Dialect/Calyx/CMakeFiles/obj.CIRCTCalyx.dir/CalyxOps.cpp.o
/home/jodemme/circt/lib/Dialect/Calyx/CalyxOps.cpp:2160:49: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ImplBinPipeOpCellInterface(MultPipeLibOp, "out");
                                                ^
/home/jodemme/circt/lib/Dialect/Calyx/CalyxOps.cpp:2161:58: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ImplBinPipeOpCellInterface(DivUPipeLibOp, "out_quotient");
                                                         ^
/home/jodemme/circt/lib/Dialect/Calyx/CalyxOps.cpp:2162:58: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ImplBinPipeOpCellInterface(DivSPipeLibOp, "out_quotient");
                                                         ^
/home/jodemme/circt/lib/Dialect/Calyx/CalyxOps.cpp:2163:59: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ImplBinPipeOpCellInterface(RemUPipeLibOp, "out_remainder");
                                                          ^
/home/jodemme/circt/lib/Dialect/Calyx/CalyxOps.cpp:2164:59: warning: extra ';' outside of a function is incompatible with C++98 [-Wc++98-compat-extra-semi]
ImplBinPipeOpCellInterface(RemSPipeLibOp, "out_remainder");
                                                          ^
5 warnings generated.
[2942/3241] Building CXX object tools/circt/lib/Dialect/ESI/CMakeFiles/obj.CIRCTESI.dir/ESIServices.cpp.o
/home/jodemme/circt/lib/Dialect/ESI/ESIServices.cpp:506:14: warning: unused variable 'modTerminator' [-Wunused-variable]
  Operation *modTerminator = modBlock.getTerminator();
             ^
1 warning generated.
[2956/3241] Building CXX object tools/circt/lib/Dialect/FIRRTL/CMakeFiles/obj.CIRCTFIRRTL.dir/FIRRTLTypes.cpp.o
In file included from /home/jodemme/circt/lib/Dialect/FIRRTL/FIRRTLTypes.cpp:32:
/home/jodemme/circt_build/tools/circt/include/circt/Dialect/FIRRTL/FIRRTLTypes.cpp.inc:22:36: warning: unused function 'generatedTypeParser' [-Wunused-function]
static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
                                   ^
/home/jodemme/circt_build/tools/circt/include/circt/Dialect/FIRRTL/FIRRTLTypes.cpp.inc:46:30: warning: unused function 'generatedTypePrinter' [-Wunused-function]
static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
                             ^
2 warnings generated.
[2969/3241] Building CXX object tools/circt/lib/Dialect/FIRRTL/Transforms/CMakeFiles/obj.CIRCTFIRRTLTransforms.dir/Dedup.cpp.o
/home/jodemme/circt/lib/Dialect/FIRRTL/Transforms/Dedup.cpp:56:3: warning: 'ArrayRef' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  ArrayRef bytes(reinterpret_cast<const uint8_t *>(data.c_str()),
  ^
/home/jodemme/circt/llvm/llvm/../mlir/include/mlir/Support/LLVM.h:46:7: note: add a deduction guide to suppress this warning
class ArrayRef;
      ^
/home/jodemme/circt/lib/Dialect/FIRRTL/Transforms/Dedup.cpp:89:16: warning: 'ArrayRef' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
    sha.update(ArrayRef(addr, sizeof pointer));
               ^
/home/jodemme/circt/llvm/llvm/../mlir/include/mlir/Support/LLVM.h:46:7: note: add a deduction guide to suppress this warning
class ArrayRef;
      ^
/home/jodemme/circt/lib/Dialect/FIRRTL/Transforms/Dedup.cpp:94:16: warning: 'ArrayRef' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
    sha.update(ArrayRef(addr, sizeof value));
               ^
/home/jodemme/circt/llvm/llvm/../mlir/include/mlir/Support/LLVM.h:46:7: note: add a deduction guide to suppress this warning
class ArrayRef;
      ^
/home/jodemme/circt/lib/Dialect/FIRRTL/Transforms/Dedup.cpp:790:42: warning: 'ArrayRef' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
          cloneAnnotation(nlaRefs, anno, ArrayRef(anno.begin(), anno.end()),
                                         ^
/home/jodemme/circt/llvm/llvm/../mlir/include/mlir/Support/LLVM.h:46:7: note: add a deduction guide to suppress this warning
class ArrayRef;
      ^
4 warnings generated.
[2972/3241] Building CXX object tools/circt/lib/Dialect/FIRRTL/Transforms/CMakeFiles/obj.CIRCTFIRRTLTransforms.dir/GrandCentral.cpp.o
/home/jodemme/circt/lib/Dialect/FIRRTL/Transforms/GrandCentral.cpp:1918:12: warning: 'Optional' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
    return Optional(id);
           ^
/home/jodemme/circt/llvm/llvm/include/llvm/ADT/APInt.h:34:29: note: add a deduction guide to suppress this warning
template <typename T> class Optional;
                            ^
1 warning generated.
[3030/3241] Building CXX object tools/circt/lib/Dialect/LLHD/IR/CMakeFiles/obj.CIRCTLLHD.dir/LLHDOps.cpp.o
/home/jodemme/circt/lib/Dialect/LLHD/IR/LLHDOps.cpp:501:3: warning: 'StringSet' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  llvm::StringSet sigSet;
  ^
/home/jodemme/circt/llvm/llvm/include/llvm/ADT/StringSet.h:23:7: note: add a deduction guide to suppress this warning
class StringSet : public StringMap<NoneType, AllocatorTy> {
      ^
/home/jodemme/circt/lib/Dialect/LLHD/IR/LLHDOps.cpp:502:3: warning: 'StringSet' may not intend to support class template argument deduction [-Wctad-maybe-unsupported]
  llvm::StringSet instSet;
  ^
/home/jodemme/circt/llvm/llvm/include/llvm/ADT/StringSet.h:23:7: note: add a deduction guide to suppress this warning
class StringSet : public StringMap<NoneType, AllocatorTy> {
      ^
2 warnings generated.

Closing comment (2022-10-19T23:15:25Z): Thanks for filing this! I think this is a dupe of: #3943
These have been showing up for a while. 😢