[Lldb-commits] [PATCH] D61994: [CommandInterpreter] Refactor SourceInitFile

Jonas Devlieghere via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Wed May 15 23:31:38 PDT 2019

JDevlieghere created this revision.
JDevlieghere added reviewers: labath, xiaobai, jingham.
Herald added a project: LLDB.
JDevlieghere marked 2 inline comments as done.
JDevlieghere added inline comments.

Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2118
+void CommandInterpreter::SourceInitFile(FileSpec file,
                                         CommandReturnObject &result) {
+  if (!FileSystem::Instance().Exists(file)) {
This should also have an `assert(!m_skip_lldbinit_files);`

Comment at: lldb/source/Interpreter/CommandInterpreter.cpp:2163
+    result.AppendErrorWithFormat(
+        "There is a .lldbinit file in the current directory which is not "
+        "being read.\n"
This should be reflowed. 

I was looking at the current implementation of `SourceInitFile` and there were a few things that made this function hard to read. The code to find the ~/.lldbinit file is duplicated across the cwd and non-cwd branch. The `./.lldbinit` is once computed by resolving `.lldbinit` and once by resolving `./.lldbinit`. Furthermore it wasn't clear to me what happened when you're sourcing the `.lldbinit` file in the current working directory. Apparently we do nothing when we property to control that is set to warn (makes sense) and we don't care when the property is set to true (debatable). Finally, there were at least two branches where the status of the CommandReturnObject were not set.

Anyway, this is an attempt to simplify this code a bit. It's still more complex than I had hoped.

Please let me know if you think it's more readable or not.




-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61994.199753.patch
Type: text/x-patch
Size: 9554 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190516/52b4e85b/attachment.bin>

More information about the lldb-commits mailing list