[FileSpec] Make style argument mandatory for SetFile. NFC

SetFile has an optional style argument which defaulted to the native
style. This patch makes that argument mandatory so clients of the
FileSpec class are forced to think about the correct syntax.

At the same time this introduces a (protected) convenience method to
update the file from within the FileSpec class that keeps the current
style.

These two changes together prevent a potential pitfall where the style
might be forgotten, leading to the path being updated and the style
unintentionally being changed to the host style.

llvm-svn: 334663
This commit is contained in:
Jonas Devlieghere
2018-06-13 22:08:14 +00:00
parent 07570f55e4
commit 937348cd13
50 changed files with 153 additions and 109 deletions

View File

@@ -501,7 +501,8 @@ lldb::SBProcess SBTarget::AttachToProcessWithName(
if (name && target_sp) {
ProcessAttachInfo attach_info;
attach_info.GetExecutableFile().SetFile(name, false);
attach_info.GetExecutableFile().SetFile(name, false,
FileSpec::Style::native);
attach_info.SetWaitForLaunch(wait_for);
if (listener.IsValid())
attach_info.SetListener(listener.GetSP());
@@ -1468,7 +1469,7 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
if (target_sp) {
ModuleSpec module_spec;
if (path)
module_spec.GetFileSpec().SetFile(path, false);
module_spec.GetFileSpec().SetFile(path, false, FileSpec::Style::native);
if (uuid_cstr)
module_spec.GetUUID().SetFromCString(uuid_cstr);
@@ -1480,7 +1481,8 @@ lldb::SBModule SBTarget::AddModule(const char *path, const char *triple,
module_spec.GetArchitecture() = target_sp->GetArchitecture();
if (symfile)
module_spec.GetSymbolFileSpec().SetFile(symfile, false);
module_spec.GetSymbolFileSpec().SetFile(symfile, false,
FileSpec::Style::native);
sb_module.SetSP(target_sp->GetSharedModule(module_spec));
}