[clang-tools-extra] [clang-query] Load queries and matchers from file during REPL cycle (PR #90603)

Chris Warner via cfe-commits cfe-commits at lists.llvm.org
Thu May 9 16:55:45 PDT 2024


================
@@ -281,5 +282,26 @@ const QueryKind SetQueryKind<bool>::value;
 const QueryKind SetQueryKind<OutputKind>::value;
 #endif
 
+bool FileQuery::run(llvm::raw_ostream &OS, QuerySession &QS) const {
+  auto Buffer = llvm::MemoryBuffer::getFile(StringRef{File}.trim());
+  if (!Buffer) {
+    if (Prefix.has_value())
+      llvm::errs() << *Prefix << ": ";
+    llvm::errs() << "cannot open " << File << ": "
+                 << Buffer.getError().message() << "\n";
----------------
cwarner-8702 wrote:

Got any tips on using `TextDiagnostic`?  I am struggling to figure out what to pass as the `LangOptions` and `DiagnosticOptions` considering the error isn't coming from code per-se (getting the `ASTContext` from one of the `ASTUnit` objects and the options from it seems too hacky)

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


More information about the cfe-commits mailing list