[Lldb-commits] [lldb] r334518 - Refactor ExecuteAndWait to take StringRefs.
Zachary Turner via lldb-commits
lldb-commits at lists.llvm.org
Tue Jun 12 10:43:52 PDT 2018
Author: zturner
Date: Tue Jun 12 10:43:52 2018
New Revision: 334518
URL: http://llvm.org/viewvc/llvm-project?rev=334518&view=rev
Log:
Refactor ExecuteAndWait to take StringRefs.
This simplifies some code which had StringRefs to begin with, and
makes other code more complicated which had const char* to begin
with.
In the end, I think this makes for a more idiomatic and platform
agnostic API. Not all platforms launch process with null terminated
c-string arrays for the environment pointer and argv, but the api
was designed that way because it allowed easy pass-through for
posix-based platforms. There's a little additional overhead now
since on posix based platforms we'll be takign StringRefs which
were constructed from null terminated strings and then copying
them to null terminate them again, but from a readability and
usability standpoint of the API user, I think this API signature
is strictly better.
Modified:
lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp
Modified: lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp?rev=334518&r1=334517&r2=334518&view=diff
==============================================================================
--- lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp (original)
+++ lldb/trunk/unittests/ObjectFile/ELF/TestObjectFileELF.cpp Tue Jun 12 10:43:52 2018
@@ -61,11 +61,12 @@ TEST_F(ObjectFileELFTest, SectionsResolv
"sections-resolve-consistently-%%%%%%", "obj", obj));
llvm::FileRemover remover(obj);
- const char *args[] = {YAML2OBJ, yaml.c_str(), nullptr};
+ llvm::StringRef args[] = {YAML2OBJ, yaml};
llvm::StringRef obj_ref = obj;
const llvm::Optional<llvm::StringRef> redirects[] = {llvm::None, obj_ref,
llvm::None};
- ASSERT_EQ(0, llvm::sys::ExecuteAndWait(YAML2OBJ, args, nullptr, redirects));
+ ASSERT_EQ(0,
+ llvm::sys::ExecuteAndWait(YAML2OBJ, args, llvm::None, redirects));
uint64_t size;
ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));
ASSERT_GT(size, 0u);
Modified: lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp?rev=334518&r1=334517&r2=334518&view=diff
==============================================================================
--- lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp (original)
+++ lldb/trunk/unittests/Symbol/TestDWARFCallFrameInfo.cpp Tue Jun 12 10:43:52 2018
@@ -96,11 +96,12 @@ void DWARFCallFrameInfoTest::TestBasic(D
"basic-call-frame-info-%%%%%%", "obj", obj));
llvm::FileRemover obj_remover(obj);
- const char *args[] = {YAML2OBJ, yaml.c_str(), nullptr};
+ llvm::StringRef args[] = {YAML2OBJ, yaml};
llvm::StringRef obj_ref = obj;
const llvm::Optional<llvm::StringRef> redirects[] = {llvm::None, obj_ref,
llvm::None};
- ASSERT_EQ(0, llvm::sys::ExecuteAndWait(YAML2OBJ, args, nullptr, redirects));
+ ASSERT_EQ(0,
+ llvm::sys::ExecuteAndWait(YAML2OBJ, args, llvm::None, redirects));
uint64_t size;
ASSERT_NO_ERROR(llvm::sys::fs::file_size(obj, size));
More information about the lldb-commits
mailing list