[llvm] [Support][NFC] Avoid weak vtable warning for JSON ParseError (PR #182511)

via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 20 07:19:42 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Alexis Engelke (aengelke)

<details>
<summary>Changes</summary>



---
Full diff: https://github.com/llvm/llvm-project/pull/182511.diff


2 Files Affected:

- (modified) llvm/include/llvm/Support/JSON.h (+1-3) 
- (modified) llvm/lib/Support/JSON.cpp (+5) 


``````````diff
diff --git a/llvm/include/llvm/Support/JSON.h b/llvm/include/llvm/Support/JSON.h
index ad4f891f99bb7..27862eb7ab6bb 100644
--- a/llvm/include/llvm/Support/JSON.h
+++ b/llvm/include/llvm/Support/JSON.h
@@ -918,9 +918,7 @@ class ParseError : public llvm::ErrorInfo<ParseError> {
   LLVM_ABI static char ID;
   ParseError(const char *Msg, unsigned Line, unsigned Column, unsigned Offset)
       : Msg(Msg), Line(Line), Column(Column), Offset(Offset) {}
-  void log(llvm::raw_ostream &OS) const override {
-    OS << llvm::formatv("[{0}:{1}, byte={2}]: {3}", Line, Column, Offset, Msg);
-  }
+  void log(llvm::raw_ostream &OS) const override;
   std::error_code convertToErrorCode() const override {
     return llvm::inconvertibleErrorCode();
   }
diff --git a/llvm/lib/Support/JSON.cpp b/llvm/lib/Support/JSON.cpp
index e9fd8f8fae1fa..33901a96d0ec5 100644
--- a/llvm/lib/Support/JSON.cpp
+++ b/llvm/lib/Support/JSON.cpp
@@ -688,8 +688,13 @@ Expected<Value> parse(StringRef JSON) {
         return std::move(E);
   return P.takeError();
 }
+
 char ParseError::ID = 0;
 
+void ParseError::log(llvm::raw_ostream &OS) const {
+  OS << llvm::formatv("[{0}:{1}, byte={2}]: {3}", Line, Column, Offset, Msg);
+}
+
 bool isUTF8(llvm::StringRef S, size_t *ErrOffset) {
   // Fast-path for ASCII, which is valid UTF-8.
   if (LLVM_LIKELY(isASCII(S)))

``````````

</details>


https://github.com/llvm/llvm-project/pull/182511


More information about the llvm-commits mailing list