[LINT] Fix -Wextra (#4804)
authorTianqi Chen <tqchen@users.noreply.github.com>
Tue, 4 Feb 2020 04:47:51 +0000 (20:47 -0800)
committerGitHub <noreply@github.com>
Tue, 4 Feb 2020 04:47:51 +0000 (18:47 -1000)
* [LINT] Fix -Wextra

* Fix virtual-dtor

18 files changed:
include/tvm/ir/attrs.h
include/tvm/ir/op.h
include/tvm/ir/type_relation.h
include/tvm/node/container.h
include/tvm/relay/expr.h
include/tvm/runtime/object.h
include/tvm/tir/expr.h
src/ir/attr_functor.h
src/ir/op.cc
src/relay/backend/compile_engine.h
src/relay/backend/contrib/codegen_c/codegen_c.h
src/relay/pass/combine_parallel_op.h
src/relay/pass/partial_eval.cc
src/relay/pass/transform_layout.h
src/relay/qnn/util.h
src/runtime/library_module.h
src/target/source/codegen_cuda.cc
vta/src/runtime.cc

index 1d02bf708ee3ff0fa14d27fb7392b4743f52ac5b..1fc28c817cd4d7c3168613293690fbc181e23e76 100644 (file)
@@ -222,6 +222,8 @@ class BaseAttrsNode : public Object {
  public:
   using TVMArgs = runtime::TVMArgs;
   using TVMRetValue = runtime::TVMRetValue;
+  /*! \brief virtual destructor */
+  virtual ~BaseAttrsNode() {}
   // visit function
   virtual void VisitAttrs(AttrVisitor* v) {}
   /*!
index e281c199fd47676498c77de08c1a1937cd9c4317..8a6ab77427fbbf348ceddb122c8272b25c649e6a 100644 (file)
@@ -192,7 +192,7 @@ class Op : public RelayExpr {
    * \param key The attribute key
    * \return bool True if the key is present
    */
-  TVM_DLL static const bool HasGenericAttr(const std::string& key);
+  TVM_DLL static bool HasGenericAttr(const std::string& key);
 };
 
 /*!
index 962eea31dca7c961fdc24c7c3b6e95eab2e51e21..6d4e75a23f6b88be580bcaa7efbfd389913e644a 100644 (file)
@@ -76,6 +76,8 @@ class TypeCall : public Type {
  */
 class TypeReporterNode : public Object {
  public:
+  /*! \brief virtual destructor */
+  virtual ~TypeReporterNode() {}
   /*!
    * \brief Create a type equality constraint.
    *
index f5c71980d9b4a125bdeaa8246abd3bb45b614d6b..a541385bb575887d71d638240aa97d95243f4cca 100644 (file)
@@ -150,14 +150,14 @@ class Array : public ObjectRef {
    * \brief move constructor
    * \param other source
    */
-  Array(Array<T> && other) {  // NOLINT(*)
+  Array(Array<T> && other) : ObjectRef() {  // NOLINT(*)
     data_ = std::move(other.data_);
   }
   /*!
    * \brief copy constructor
    * \param other source
    */
-  Array(const Array<T> &other) { // NOLINT(*)
+  Array(const Array<T> &other) : ObjectRef() { // NOLINT(*)
     data_ = std::move(other.data_);
   }
   /*!
index 72523dd08dd3bdf72eb5e16f904585e5c21608f9..64f2278c3103629a654c79b41fd357c27d0f4ad7 100644 (file)
@@ -526,6 +526,8 @@ class RefWrite : public Expr {
  */
 class TempExprNode : public ExprNode {
  public:
+  /*! \brief virtual destructor */
+  virtual ~TempExprNode() {}
   /*!
    * \brief Convert the expression to a normal(non-temp) Expr.
    * \return The corresponding normal(non-temp) expression.
index ba84b5f101196b65edee3b54dc472496d478e0bd..fe5e30bba2e8a804de59fcd7cc06404be419d55b 100644 (file)
@@ -649,13 +649,13 @@ struct ObjectEqual {
  */
 #define TVM_DECLARE_BASE_OBJECT_INFO(TypeName, ParentType)              \
   static_assert(!ParentType::_type_final, "ParentObj maked as final");  \
-  static const uint32_t RuntimeTypeIndex()  {                           \
+  static uint32_t RuntimeTypeIndex()  {                                 \
     if (TypeName::_type_index != ::tvm::runtime::TypeIndex::kDynamic) { \
       return TypeName::_type_index;                                     \
     }                                                                   \
     return _GetOrAllocRuntimeTypeIndex();                               \
   }                                                                     \
-  static const uint32_t _GetOrAllocRuntimeTypeIndex()  {                \
+  static uint32_t _GetOrAllocRuntimeTypeIndex()  {                      \
     static uint32_t tidx = Object::GetOrAllocRuntimeTypeIndex(          \
         TypeName::_type_key,                                            \
         TypeName::_type_index,                                          \
index 93b04db7562a980aa4ba6a607c0b980fd2ee90bf..756907bfef475b71a523bb3601b91f496518f469 100644 (file)
@@ -731,6 +731,8 @@ class LetNode : public PrimExprNode {
 /*! \brief Base node of internal functions. */
 class FunctionBaseNode : public Object {
  public:
+  /*! \brief virtual destructor */
+  virtual ~FunctionBaseNode() {}
   /*! \return the name of the function */
   virtual const std::string& func_name() const = 0;
   /*! \return the number of outputs of this function */
index 49431407a6eee25db82b876f2ccff8a39e4de4a6..babd08a83c6eab5a92a3f6f08eee4255247a93b8 100644 (file)
@@ -60,6 +60,8 @@ class AttrFunctor<R(const ObjectRef& n, Args...)> {
  public:
   /*! \brief the result type of this functor */
   using result_type = R;
+  /*! \brief virtual destructor */
+  virtual ~AttrFunctor() {}
   /*!
    * \brief The functor call.
    * \param n The expression node.
index 558b69891ae64b0921d9258f769c41bca2c37e95..b25fe999443a18cbe13d8916110f45c4cd7f0618 100644 (file)
@@ -87,7 +87,7 @@ const GenericOpMap& Op::GetGenericAttr(const std::string& key) {
 }
 
 // Check if a key is present in the registry.
-const bool Op::HasGenericAttr(const std::string& key) {
+bool Op::HasGenericAttr(const std::string& key) {
   OpManager* mgr = OpManager::Global();
   std::lock_guard<std::mutex> lock(mgr->mutex);
   auto it = mgr->attr.find(key);
index 42142f1377a72c209ccb99fafac5428e41d25eb0..15ec2d6bd0f1894f544b46b8f677a032c300a8a5 100644 (file)
@@ -171,6 +171,8 @@ class CCacheValue : public ObjectRef {
  */
 class CompileEngineNode : public Object {
  public:
+  /*! \brief destructor */
+  virtual ~CompileEngineNode() {}
   /*!
    * \brief Get lowered result.
    * \param key The key to the cached function.
index 23e07d55dac90bb4d8dff60d6bb1b6a95087325f..f473c93a2896cfdbd04a9ff366af183153606ad8 100644 (file)
@@ -38,6 +38,7 @@ namespace contrib {
 class CSourceModuleCodegenBase {
  public:
   CSourceModuleCodegenBase() = default;
+  virtual ~CSourceModuleCodegenBase() = default;
 
   /*!
    * \brief Create a runtime module for the external library. For example, it
@@ -69,6 +70,9 @@ class CSourceModuleCodegenBase {
 
 // The base class to generate the declaration functions in C.
 class CodegenCBase {
+ public:
+  virtual ~CodegenCBase() {}
+
  protected:
   /*! \brief Print indents using spaces. */
   void PrintIndents() {
index 619a153595b72dc84d14719471a7356d7defa3b1..24f3884f4b11cb31345ee1a6e741eb44ab047605 100644 (file)
@@ -126,6 +126,8 @@ class BranchGroupFinder : private ExprVisitor {
  */
 class ParallelOpCombiner {
  public:
+  /*! \brief virtual destructor */
+  virtual ~ParallelOpCombiner() {}
   /*
    * \brief Constructor.
    * \param op_name name of op to combine
index 37ce34817787e14e84b47348fb42af90ed7b11f2..c5857c26b7a955bde20207a1564fa185c30ff6e9 100644 (file)
@@ -275,6 +275,7 @@ class Fuel : public ObjectRef {
 
 class FuelNode : public RelayNode {
  public:
+  virtual ~FuelNode() {}
   // Please implement one of the following function or there will be infinite loop.
   /*! \brief return the new Fuel, and whether progress is made.
    *
index f7845242d21b7d6521cca753c98599cb31cb58c3..f18f5d26f2487431bebf95be43813f4a06716596 100644 (file)
@@ -70,6 +70,8 @@ class TransformMemorizer : public ObjectRef {
   TransformMemorizer() {}
   explicit TransformMemorizer(ObjectPtr<Object> n) : ObjectRef(n) {}
 
+  virtual ~TransformMemorizer() {}
+
   TransformMemorizerNode* operator->() {
     return static_cast<TransformMemorizerNode*>(get_mutable());
   }
index 6362421f051bf38bfe048fb3fb9aad4016c0aee1..0bab94796299b7bde945f916ec855a83f3c820d6 100644 (file)
@@ -45,7 +45,7 @@ static inline Array<IndexExpr> get_shape(const Type& type) {
   return input_tt->shape;
 }
 
-static inline const int32_t GetQmin(const DataType& dtype) {
+static inline int32_t GetQmin(const DataType& dtype) {
   CHECK_LE(dtype.bits(), 32)
       << "QNN ops support int32 or lower precision";
   if (dtype.is_int() || dtype.is_uint()) {
@@ -58,7 +58,7 @@ static inline const int32_t GetQmin(const DataType& dtype) {
   }
 }
 
-static inline const int32_t GetQmax(const DataType& dtype) {
+static inline int32_t GetQmax(const DataType& dtype) {
   CHECK_LE(dtype.bits(), 32)
       << "QNN ops support int32 or lower precision";
   if (dtype.is_int() || dtype.is_uint()) {
index 8e84a4b48bd3c96bf27a6d87856b439544d28ac8..61e62661f149e48a0c667b8ab7e5ffdb7c9c2d6d 100644 (file)
@@ -40,6 +40,8 @@ namespace runtime {
  */
 class Library : public Object {
  public:
+  // destructor.
+  virtual ~Library() {}
   /*!
    * \brief Get the symbol address for a given name.
    * \param name The name of the symbol.
index 5a3130f319956dc1d5aa5a4a93f2ca5bc12de0c4..0b2c54e592ce18ea066d0e6abc73676ece7555ec 100644 (file)
@@ -190,6 +190,7 @@ void CodeGenCUDA::PrintType(DataType t, std::ostream& os) {  // NOLINT(*)
           } else {
             // No longlong3, longlong4
             LOG(FATAL) << "Cannot convert type " << t << " to CUDA type on a L32 platform";
+            break;
           }
         } else {
           os << "long"; break;
index aa42a4c1c0c4f8f161b2fbfa5bb66e9f6c9bee17..6b08c6c2ebcd8e6c85dd1a6eb935202278cde78b 100644 (file)
@@ -314,7 +314,7 @@ class UopKernel {
 template <class T>
 class BaseQueue {
  public:
-  ~BaseQueue() {
+  virtual ~BaseQueue() {
     if (fpga_buff_ != nullptr) {
       VTAMemFree(fpga_buff_);
     }