[Lldb-commits] [lldb] 4857b6f - Revert "Store OptTable::Info::Name as a StringRef"

2022-12-06 Thread Douglas Yung via lldb-commits

Author: Douglas Yung
Date: 2022-12-06T19:37:05-08:00
New Revision: 4857b6f8fff614c89ed35031c298df81394459af

URL: 
https://github.com/llvm/llvm-project/commit/4857b6f8fff614c89ed35031c298df81394459af
DIFF: 
https://github.com/llvm/llvm-project/commit/4857b6f8fff614c89ed35031c298df81394459af.diff

LOG: Revert "Store OptTable::Info::Name as a StringRef"

This reverts commit 5951b0bb23f3265bea16f28c2af9d278b9d829c6.

This is causing 24 test failures on the PS4 linux bot: 
https://lab.llvm.org/buildbot/#/builders/139/builds/32263

Added: 


Modified: 
clang/lib/Driver/ToolChains/Gnu.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
llvm/include/llvm/ADT/StringRef.h
llvm/include/llvm/Option/OptTable.h
llvm/lib/Option/OptTable.cpp
llvm/unittests/Option/OptionMarshallingTest.cpp
llvm/utils/TableGen/OptParserEmitter.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index 60d62e2b9c5c1..4621850f13772 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -331,8 +331,8 @@ static bool getStaticPIE(const ArgList &Args, const 
ToolChain &TC) {
   if (HasStaticPIE && Args.hasArg(options::OPT_nopie)) {
 const Driver &D = TC.getDriver();
 const llvm::opt::OptTable &Opts = D.getOpts();
-StringRef StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
-StringRef NoPIEName = Opts.getOptionName(options::OPT_nopie);
+const char *StaticPIEName = Opts.getOptionName(options::OPT_static_pie);
+const char *NoPIEName = Opts.getOptionName(options::OPT_nopie);
 D.Diag(diag::err_drv_cannot_mix_options) << StaticPIEName << NoPIEName;
   }
   return HasStaticPIE;

diff  --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp 
b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
index fde098840be4b..9d89148616be1 100644
--- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
+++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
@@ -1055,7 +1055,7 @@ void 
PlatformDarwin::AddClangModuleCompilationOptionsForSDKType(
   // Only add the version-min options if we got a version from somewhere
   if (!version.empty() && sdk_type != XcodeSDK::Type::Linux) {
 #define OPTION(PREFIX, NAME, VAR, ...) 
\
-  llvm::StringRef opt_##VAR = NAME;
\
+  const char *opt_##VAR = NAME;
\
   (void)opt_##VAR;
 #include "clang/Driver/Options.inc"
 #undef OPTION

diff  --git a/llvm/include/llvm/ADT/StringRef.h 
b/llvm/include/llvm/ADT/StringRef.h
index 9fea390c2ed32..032f42a51ec0b 100644
--- a/llvm/include/llvm/ADT/StringRef.h
+++ b/llvm/include/llvm/ADT/StringRef.h
@@ -561,8 +561,7 @@ namespace llvm {
 /// \param N The number of characters to included in the substring. If N
 /// exceeds the number of characters remaining in the string, the string
 /// suffix (starting with \p Start) will be returned.
-[[nodiscard]] constexpr StringRef substr(size_t Start,
- size_t N = npos) const {
+[[nodiscard]] StringRef substr(size_t Start, size_t N = npos) const {
   Start = std::min(Start, Length);
   return StringRef(Data + Start, std::min(N, Length - Start));
 }

diff  --git a/llvm/include/llvm/Option/OptTable.h 
b/llvm/include/llvm/Option/OptTable.h
index e884ebeb788c4..07d9870f71b33 100644
--- a/llvm/include/llvm/Option/OptTable.h
+++ b/llvm/include/llvm/Option/OptTable.h
@@ -44,7 +44,7 @@ class OptTable {
 /// A null terminated array of prefix strings to apply to name while
 /// matching.
 const char *const *Prefixes;
-StringRef Name;
+const char *Name;
 const char *HelpText;
 const char *MetaVar;
 unsigned ID;
@@ -102,7 +102,9 @@ class OptTable {
   const Option getOption(OptSpecifier Opt) const;
 
   /// Lookup the name of the given option.
-  StringRef getOptionName(OptSpecifier id) const { return getInfo(id).Name; }
+  const char *getOptionName(OptSpecifier id) const {
+return getInfo(id).Name;
+  }
 
   /// Get the kind of the given option.
   unsigned getOptionKind(OptSpecifier id) const {
@@ -182,7 +184,7 @@ class OptTable {
   ///  takes
   ///
   /// \return true in success, and false in fail.
-  bool addValues(StringRef Option, const char *Values);
+  bool addValues(const char *Option, const char *Values);
 
   /// Parse a single argument; returning the new argument and
   /// updating Index.

diff  --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index f23561b5d078d..ef4873eb7f9c4 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -36,23 +36,31 @@ namespace opt {
 // Ordering on Info. The ordering is *almost* case-insensitive lexicographic,
 // with an exception. '\0' comes at the end of the alphabet

[Lldb-commits] [lldb] c46d9af - Revert "Host: generalise `GetXcodeSDKPath`"

2023-05-01 Thread Douglas Yung via lldb-commits

Author: Douglas Yung
Date: 2023-05-01T10:22:53-07:00
New Revision: c46d9af26cefb0b24646d3235b75ae7a1b8548d4

URL: 
https://github.com/llvm/llvm-project/commit/c46d9af26cefb0b24646d3235b75ae7a1b8548d4
DIFF: 
https://github.com/llvm/llvm-project/commit/c46d9af26cefb0b24646d3235b75ae7a1b8548d4.diff

LOG: Revert "Host: generalise `GetXcodeSDKPath`"

This reverts commit ade3c6a6a88ed3a9b06c076406f196da9d3cc1b9.

This breaks the build with GCC and affects at least 2 build bots:
https://lab.llvm.org/buildbot/#/builders/217/builds/20568
https://lab.llvm.org/buildbot/#/builders/243/builds/5576

Added: 


Modified: 
lldb/include/lldb/Host/HostInfoBase.h
lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
lldb/source/Core/Module.cpp
lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
lldb/source/Plugins/Platform/MacOSX/PlatformAppleSimulator.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/unittests/Host/HostInfoTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Host/HostInfoBase.h 
b/lldb/include/lldb/Host/HostInfoBase.h
index 28f809398d5b4..42f71d91f9bf9 100644
--- a/lldb/include/lldb/Host/HostInfoBase.h
+++ b/lldb/include/lldb/Host/HostInfoBase.h
@@ -31,23 +31,6 @@ struct SharedCacheImageInfo {
   lldb::DataBufferSP data_sp;
 };
 
-namespace {
-struct HostInfoError : public llvm::ErrorInfo {
-  static char ID;
-  const std::string message_;
-
-  HostInfoError(const std::string message) : message_(std::move(message)) {}
-
-  void log(llvm::raw_ostream &OS) const override { OS << "HostInfoError"; }
-
-  std::error_code convertToErrorCode() const override {
-return llvm::inconvertibleErrorCode();
-  }
-};
-
-char HostInfoError::ID = 0;
-} // namespace
-
 class HostInfoBase {
 private:
   // Static class, unconstructable.
@@ -125,14 +108,10 @@ class HostInfoBase {
 
   static FileSpec GetXcodeContentsDirectory() { return {}; }
   static FileSpec GetXcodeDeveloperDirectory() { return {}; }
-
-  struct SDKOptions {
-std::optional XcodeSDK;
-  };
-
-  /// Return the directory containing something like a SDK (reused for Swift).
-  static llvm::Expected GetSDKRoot(SDKOptions options) {
-return llvm::make_error("cannot determine SDK root");
+  
+  /// Return the directory containing a specific Xcode SDK.
+  static llvm::Expected GetXcodeSDKPath(XcodeSDK sdk) {
+return "";
   }
 
   /// Return information about module \p image_name if it is loaded in

diff  --git a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h 
b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
index 74d979d965a73..0402509cfa261 100644
--- a/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
+++ b/lldb/include/lldb/Host/macosx/HostInfoMacOSX.h
@@ -31,7 +31,7 @@ class HostInfoMacOSX : public HostInfoPosix {
   static FileSpec GetXcodeDeveloperDirectory();
 
   /// Query xcrun to find an Xcode SDK directory.
-  static llvm::Expected GetSDKRoot(SDKOptions options);
+  static llvm::Expected GetXcodeSDKPath(XcodeSDK sdk);
 
   /// Shared cache utilities
   static SharedCacheImageInfo

diff  --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index 6293cc7853f53..17d8043852ab7 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -1607,8 +1607,8 @@ std::optional 
Module::RemapSourceFile(llvm::StringRef path) const {
 
 void Module::RegisterXcodeSDK(llvm::StringRef sdk_name,
   llvm::StringRef sysroot) {
-  auto sdk_path_or_err =
-  HostInfo::GetSDKRoot(HostInfo::SDKOptions{sdk_name.str()});
+  XcodeSDK sdk(sdk_name.str());
+  auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(sdk);
 
   if (!sdk_path_or_err) {
 Debugger::ReportError("Error while searching for Xcode SDK: " +

diff  --git a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm 
b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
index 6569013044513..5a39ed370747a 100644
--- a/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
+++ b/lldb/source/Host/macosx/objcxx/HostInfoMacOSX.mm
@@ -338,8 +338,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   }
 }
 
-auto sdk_path_or_err =
-HostInfo::GetSDKRoot(SDKOptions{XcodeSDK::GetAnyMacOS()});
+auto sdk_path_or_err = HostInfo::GetXcodeSDKPath(XcodeSDK::GetAnyMacOS());
 if (!sdk_path_or_err) {
   Log *log = GetLog(LLDBLog::Host);
   LLDB_LOGF(log, "Error while searching for Xcode SDK: %s",
@@ -520,7 +519,7 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   return path;
 }
 
-llvm::Expected HostInfoMacOSX::GetSDKRoot(SDKOptions options) 
{
+llvm::Expected HostInfoMacOSX::GetXcodeSDKPath(XcodeSDK sdk) {
   struct ErrorOrPath {
 std::string str;
 bool is_error;
@@ -531,11 +530,6 @@ static void ParseOSVersion(llvm::VersionTuple &version, 
NSString *Key) {
   std::lock_guard guard(g_sdk_path_mutex);
   LLDB_SCOPED_TIMER();
 
-  if (!options.XcodeSDK)
-return 

[Lldb-commits] [lldb] 1d763f3 - Revert "Modify the localCache API to require an explicit commit on CachedFile… (#115331)"

2025-03-08 Thread Douglas Yung via lldb-commits

Author: Douglas Yung
Date: 2025-03-08T23:54:57Z
New Revision: 1d763f383380ec629ee6d5053fd41322efcbc6bd

URL: 
https://github.com/llvm/llvm-project/commit/1d763f383380ec629ee6d5053fd41322efcbc6bd
DIFF: 
https://github.com/llvm/llvm-project/commit/1d763f383380ec629ee6d5053fd41322efcbc6bd.diff

LOG: Revert "Modify the localCache API to require an explicit commit on 
CachedFile… (#115331)"

This reverts commit ce9e1d3c15ed6290f1cb07b482939976fa8115cd.

The unittest added in this commit seems to be flaky causing random failure on 
buildbots:
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13235
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13232
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13228
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13224
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13220
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13210
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13208
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13207
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13202
 - https://lab.llvm.org/buildbot/#/builders/46/builds/13196
and
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14266
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14254
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14250
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14245
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14244
 - https://lab.llvm.org/buildbot/#/builders/180/builds/14226

Added: 


Modified: 
lldb/source/Core/DataFileCache.cpp
llvm/include/llvm/Support/Caching.h
llvm/lib/CGData/CodeGenData.cpp
llvm/lib/Debuginfod/Debuginfod.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/Support/Caching.cpp
llvm/tools/gold/gold-plugin.cpp
llvm/tools/llvm-lto2/llvm-lto2.cpp
llvm/unittests/Support/CMakeLists.txt

Removed: 
llvm/unittests/Support/Caching.cpp



diff  --git a/lldb/source/Core/DataFileCache.cpp 
b/lldb/source/Core/DataFileCache.cpp
index 9109269711231..ef0e07a8b0342 100644
--- a/lldb/source/Core/DataFileCache.cpp
+++ b/lldb/source/Core/DataFileCache.cpp
@@ -132,11 +132,6 @@ bool DataFileCache::SetCachedData(llvm::StringRef key,
   if (file_or_err) {
 llvm::CachedFileStream *cfs = file_or_err->get();
 cfs->OS->write((const char *)data.data(), data.size());
-if (llvm::Error err = cfs->commit()) {
-  Log *log = GetLog(LLDBLog::Modules);
-  LLDB_LOG_ERROR(log, std::move(err),
- "failed to commit to the cache for key: {0}");
-}
 return true;
   } else {
 Log *log = GetLog(LLDBLog::Modules);

diff  --git a/llvm/include/llvm/Support/Caching.h 
b/llvm/include/llvm/Support/Caching.h
index 9a82921e6ffc7..cf45145619d95 100644
--- a/llvm/include/llvm/Support/Caching.h
+++ b/llvm/include/llvm/Support/Caching.h
@@ -24,32 +24,15 @@ class MemoryBuffer;
 /// This class wraps an output stream for a file. Most clients should just be
 /// able to return an instance of this base class from the stream callback, but
 /// if a client needs to perform some action after the stream is written to,
-/// that can be done by deriving from this class and overriding the destructor
-/// or the commit() method.
+/// that can be done by deriving from this class and overriding the destructor.
 class CachedFileStream {
 public:
   CachedFileStream(std::unique_ptr OS,
std::string OSPath = "")
   : OS(std::move(OS)), ObjectPathName(OSPath) {}
-
-  /// Must be called exactly once after the writes to OS have been completed
-  /// but before the CachedFileStream object is destroyed.
-  virtual Error commit() {
-if (Committed)
-  return createStringError(make_error_code(std::errc::invalid_argument),
-   Twine("CacheStream already committed."));
-Committed = true;
-
-return Error::success();
-  }
-
-  bool Committed = false;
   std::unique_ptr OS;
   std::string ObjectPathName;
-  virtual ~CachedFileStream() {
-if (!Committed)
-  report_fatal_error("CachedFileStream was not committed.\n");
-  }
+  virtual ~CachedFileStream() = default;
 };
 
 /// This type defines the callback to add a file that is generated on the fly.

diff  --git a/llvm/lib/CGData/CodeGenData.cpp b/llvm/lib/CGData/CodeGenData.cpp
index 7b9c584d64867..02de528c4d007 100644
--- a/llvm/lib/CGData/CodeGenData.cpp
+++ b/llvm/lib/CGData/CodeGenData.cpp
@@ -233,9 +233,6 @@ void saveModuleForTwoRounds(const Module &TheModule, 
unsigned Task,
 
   WriteBitcodeToFile(TheModule, *Stream->OS,
  /*ShouldPreserveUseListOrder=*/true);
-
-  if (Error Err = Stream->commit())
-report_fatal_error(std::move(Err));
 }
 
 std::unique_ptr loadModuleForTwoRounds(BitcodeModule &OrigModule,

diff  --git a/llvm/lib/Debuginfod/Debuginfod.cpp 
b/llvm/lib/Debuginfod/Debuginfod.cpp
index e570