Skip to content

Commit 8f5a221

Browse files
Merge pull request #9387 from adrian-prantl/cherry-pick-status-refactor
Cherry pick status refactor
2 parents 5c02b8d + 8064562 commit 8f5a221

File tree

379 files changed

+15791
-9835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

379 files changed

+15791
-9835
lines changed

clang/include/clang/Driver/Driver.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,7 @@ class Driver {
379379

380380
/// Takes the path to a binary that's either in bin/ or lib/ and returns
381381
/// the path to clang's resource directory.
382-
static std::string GetResourcesPath(StringRef BinaryPath,
383-
StringRef CustomResourceDir = "");
382+
static std::string GetResourcesPath(StringRef BinaryPath);
384383

385384
Driver(StringRef ClangExecutable, StringRef TargetTriple,
386385
DiagnosticsEngine &Diags, std::string Title = "clang LLVM compiler",

clang/lib/Driver/Driver.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -171,18 +171,18 @@ getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) {
171171
}
172172

173173
// static
174-
std::string Driver::GetResourcesPath(StringRef BinaryPath,
175-
StringRef CustomResourceDir) {
174+
std::string Driver::GetResourcesPath(StringRef BinaryPath) {
176175
// Since the resource directory is embedded in the module hash, it's important
177176
// that all places that need it call this function, so that they get the
178177
// exact same string ("a/../b/" and "b/" get different hashes, for example).
179178

180179
// Dir is bin/ or lib/, depending on where BinaryPath is.
181-
std::string Dir = std::string(llvm::sys::path::parent_path(BinaryPath));
182-
180+
StringRef Dir = llvm::sys::path::parent_path(BinaryPath);
183181
SmallString<128> P(Dir);
184-
if (CustomResourceDir != "") {
185-
llvm::sys::path::append(P, CustomResourceDir);
182+
183+
StringRef ConfiguredResourceDir(CLANG_RESOURCE_DIR);
184+
if (!ConfiguredResourceDir.empty()) {
185+
llvm::sys::path::append(P, ConfiguredResourceDir);
186186
} else {
187187
// On Windows, libclang.dll is in bin/.
188188
// On non-Windows, libclang.so/.dylib is in lib/.
@@ -239,7 +239,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
239239
#endif
240240

241241
// Compute the path to the resource directory.
242-
ResourceDir = GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
242+
ResourceDir = GetResourcesPath(ClangExecutable);
243243
}
244244

245245
void Driver::setDriverMode(StringRef Value) {

clang/lib/Frontend/CompilerInvocation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3378,7 +3378,7 @@ std::string CompilerInvocation::GetResourcesPath(const char *Argv0,
33783378
void *MainAddr) {
33793379
std::string ClangExecutable =
33803380
llvm::sys::fs::getMainExecutable(Argv0, MainAddr);
3381-
return Driver::GetResourcesPath(ClangExecutable, CLANG_RESOURCE_DIR);
3381+
return Driver::GetResourcesPath(ClangExecutable);
33823382
}
33833383

33843384
static void GenerateHeaderSearchArgs(const HeaderSearchOptions &Opts,

lldb/bindings/python/python-swigsafecast.swig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ PythonObject SWIGBridge::ToSWIGWrapper(lldb::BreakpointSP breakpoint_sp) {
3333
SWIGTYPE_p_lldb__SBBreakpoint);
3434
}
3535

36-
PythonObject SWIGBridge::ToSWIGWrapper(const Status& status) {
37-
return ToSWIGHelper(new lldb::SBError(status), SWIGTYPE_p_lldb__SBError);
36+
PythonObject SWIGBridge::ToSWIGWrapper(Status status) {
37+
return ToSWIGHelper(new lldb::SBError(std::move(status)), SWIGTYPE_p_lldb__SBError);
3838
}
3939

4040
PythonObject SWIGBridge::ToSWIGWrapper(std::unique_ptr<lldb::SBStructuredData> data_sb) {

lldb/bindings/python/python-wrapper.swig

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,11 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
306306
const char *session_dictionary_name, const StructuredDataImpl &args_impl,
307307
Status &error) {
308308
if (python_class_name == NULL || python_class_name[0] == '\0') {
309-
error.SetErrorString("Empty class name.");
309+
error = Status::FromErrorString("Empty class name.");
310310
return PythonObject();
311311
}
312312
if (!session_dictionary_name) {
313-
error.SetErrorString("No session dictionary");
313+
error = Status::FromErrorString("No session dictionary");
314314
return PythonObject();
315315
}
316316

@@ -322,7 +322,7 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
322322
python_class_name, dict);
323323

324324
if (!pfunc.IsAllocated()) {
325-
error.SetErrorStringWithFormat("Could not find class: %s.",
325+
error = Status::FromErrorStringWithFormat("Could not find class: %s.",
326326
python_class_name);
327327
return PythonObject();
328328
}
@@ -337,23 +337,25 @@ PythonObject lldb_private::python::SWIGBridge::LLDBSwigPythonCreateScriptedStopH
337337
if (auto args_info = callback_func.GetArgInfo()) {
338338
size_t num_args = (*args_info).max_positional_args;
339339
if (num_args != 2) {
340-
error.SetErrorStringWithFormat(
340+
error = Status::FromErrorStringWithFormat(
341341
"Wrong number of args for "
342342
"handle_stop callback, should be 2 (excluding self), got: %zu",
343343
num_args);
344344
return PythonObject();
345345
} else
346346
return result;
347347
} else {
348-
error.SetErrorString("Couldn't get num arguments for handle_stop "
349-
"callback.");
348+
error = Status::FromErrorString(
349+
"Couldn't get num arguments for handle_stop "
350+
"callback.");
350351
return PythonObject();
351352
}
352353
return result;
353354
} else {
354-
error.SetErrorStringWithFormat("Class \"%s\" is missing the required "
355-
"handle_stop callback.",
356-
python_class_name);
355+
error = Status::FromErrorStringWithFormat(
356+
"Class \"%s\" is missing the required "
357+
"handle_stop callback.",
358+
python_class_name);
357359
}
358360
}
359361
return PythonObject();

0 commit comments

Comments
 (0)