[clang][APINotes] Fix -Wunused-function warning (NFC)
authorYang Fan <nullptr.cpp@gmail.com>
Thu, 1 Apr 2021 01:16:51 +0000 (09:16 +0800)
committerYang Fan <nullptr.cpp@gmail.com>
Thu, 1 Apr 2021 01:52:43 +0000 (09:52 +0800)
GCC warning:
```
/llvm-project/clang/lib/APINotes/APINotesYAMLCompiler.cpp:574:23: warning: ‘void {anonymous}::Module::dump()’ defined but not used [-Wunused-function]
  574 | LLVM_DUMP_METHOD void Module::dump() {
      |                       ^~~~~~
```

clang/lib/APINotes/APINotesYAMLCompiler.cpp

index cf50e26..75100fd 100644 (file)
@@ -551,7 +551,9 @@ struct Module {
 
   llvm::Optional<bool> SwiftInferImportAsMember = {llvm::None};
 
-  void dump() /*const*/;
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+  LLVM_DUMP_METHOD void dump() /*const*/;
+#endif
 };
 } // namespace
 
@@ -571,10 +573,12 @@ template <> struct MappingTraits<Module> {
 } // namespace yaml
 } // namespace llvm
 
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
 LLVM_DUMP_METHOD void Module::dump() {
   llvm::yaml::Output OS(llvm::errs());
   OS << *this;
 }
+#endif
 
 namespace {
 bool parseAPINotes(StringRef YI, Module &M, llvm::SourceMgr::DiagHandlerTy Diag,