================
@@ -0,0 +1,713 @@
+#include "clang/Analysis/Scalable/Serialization/JSONFormat.h"
+#include "clang/Analysis/Scalable/TUSummary/TUSummary.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Registry.h"
+
+using namespace clang::ssaf;
+
+namespace {
+// Helper to wrap an error with additional context
+template <typename... Args>
+llvm::Error wrapError(llvm::Error E, std::errc ErrorCode, const char *Fmt,
+ Args &&...Vals) {
+ return llvm::joinErrors(
+ llvm::createStringError(ErrorCode, Fmt, std::forward<Args>(Vals)...),
+ std::move(E));
+}
+
+// Convenience version that defaults to invalid_argument
+template <typename... Args>
+llvm::Error wrapError(llvm::Error E, const char *Fmt, Args &&...Vals) {
+ return wrapError(std::move(E), std::errc::invalid_argument, Fmt,
+ std::forward<Args>(Vals)...);
+}
+
+} // namespace
+
+//----------------------------------------------------------------------------
+// JSON Reader and Writer
+//----------------------------------------------------------------------------
+
+llvm::Error isJSONFile(llvm::StringRef Path) {
+ if (!llvm::sys::fs::exists(Path))
+ return llvm::createStringError(std::errc::no_such_file_or_directory,
+ "file does not exist: '%s'",
+ Path.str().c_str());
+
+ if (llvm::sys::fs::is_directory(Path))
+ return llvm::createStringError(std::errc::is_a_directory,
----------------
aviralg wrote:
Path tested by `error-is-directory.test`
https://github.com/llvm/llvm-project/pull/180021
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits