-
Notifications
You must be signed in to change notification settings - Fork 344
[lldb] add de-duplication and working dir support for fmodule-file #4039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -268,19 +268,82 @@ TEST_F(TestSwiftASTContext, ApplyWorkingDir) { | |
EXPECT_EQ( | ||
single_arg_rel_path, | ||
llvm::SmallString<128>("-fmodule-map-file=rel/dir/module.modulemap")); | ||
|
||
// fmodule-file needs to handle different cases: | ||
// -fmodule-file=path/to/pcm | ||
// -fmodule-file=name=path/to/pcm | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here it says There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, this isn't a key=value pair whre the key is "name", it's [name of the module]=[file name]! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Exactly, yes. I believe the idea is that the compiler can avoid loading pcm files until they are imported. |
||
llvm::SmallString<128> module_file_abs_path( | ||
"-fmodule-file=/some/dir/module.pcm"); | ||
SwiftASTContext::ApplyWorkingDir(module_file_abs_path, abs_working_dir); | ||
EXPECT_EQ(module_file_abs_path, | ||
llvm::SmallString<128>("-fmodule-file=/some/dir/module.pcm")); | ||
|
||
llvm::SmallString<128> module_file_rel_path( | ||
"-fmodule-file=relpath/module.pcm"); | ||
SwiftASTContext::ApplyWorkingDir(module_file_rel_path, abs_working_dir); | ||
EXPECT_EQ( | ||
module_file_rel_path, | ||
llvm::SmallString<128>("-fmodule-file=/abs/dir/relpath/module.pcm")); | ||
|
||
llvm::SmallString<128> module_file_with_name_abs_path( | ||
"-fmodule-file=modulename=/some/dir/module.pcm"); | ||
SwiftASTContext::ApplyWorkingDir(module_file_with_name_abs_path, | ||
abs_working_dir); | ||
EXPECT_EQ( | ||
module_file_with_name_abs_path, | ||
llvm::SmallString<128>("-fmodule-file=modulename=/some/dir/module.pcm")); | ||
|
||
llvm::SmallString<128> module_file_with_name_rel_path( | ||
"-fmodule-file=modulename=relpath/module.pcm"); | ||
SwiftASTContext::ApplyWorkingDir(module_file_with_name_rel_path, | ||
abs_working_dir); | ||
EXPECT_EQ(module_file_with_name_rel_path, | ||
llvm::SmallString<128>( | ||
"-fmodule-file=modulename=/abs/dir/relpath/module.pcm")); | ||
} | ||
|
||
namespace { | ||
const std::vector<std::string> duplicated_flags = { | ||
"-DMACRO1", "-D", "MACRO1", "-UMACRO2", "-U", "MACRO2", | ||
"-I/path1", "-I", "/path1", "-F/path2", "-F", "/path2", | ||
"-fmodule-map-file=/path3", "-fmodule-map-file=/path3", | ||
"-F/path2", "-F", "/path2", "-I/path1", "-I", "/path1", | ||
"-UMACRO2", "-U", "MACRO2", "-DMACRO1", "-D", "MACRO1", | ||
}; | ||
const std::vector<std::string> uniqued_flags = { | ||
"-DMACRO1", "-UMACRO2", "-I/path1", "-F/path2", "-fmodule-map-file=/path3" | ||
}; | ||
const std::vector<std::string> duplicated_flags = { | ||
"-DMACRO1", | ||
"-D", | ||
"MACRO1", | ||
"-UMACRO2", | ||
"-U", | ||
"MACRO2", | ||
"-I/path1", | ||
"-I", | ||
"/path1", | ||
"-F/path2", | ||
"-F", | ||
"/path2", | ||
"-fmodule-map-file=/path3", | ||
"-fmodule-map-file=/path3", | ||
"-F/path2", | ||
"-F", | ||
"/path2", | ||
"-I/path1", | ||
"-I", | ||
"/path1", | ||
"-UMACRO2", | ||
"-U", | ||
"MACRO2", | ||
"-DMACRO1", | ||
"-D", | ||
"MACRO1", | ||
"-fmodule-file=/path/to/pcm", | ||
"-fmodule-file=/path/to/pcm", | ||
"-fmodule-file=modulename=/path/to/pcm", | ||
"-fmodule-file=modulename=/path/to/pcm", | ||
}; | ||
const std::vector<std::string> uniqued_flags = { | ||
"-DMACRO1", | ||
"-UMACRO2", | ||
"-I/path1", | ||
"-F/path2", | ||
"-fmodule-map-file=/path3", | ||
"-fmodule-file=/path/to/pcm", | ||
"-fmodule-file=modulename=/path/to/pcm", | ||
}; | ||
} // namespace | ||
|
||
TEST(ClangArgs, UniquingCollisionWithExistingFlags) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is safe, even if arg is either "foo", or "foo="?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The two valid cases are
-fmodule-file=some/path
and-fmodule-file=modulename=some/path
. We know the first=
is present as we checked the prefix above, so this will split correctly in both cases. There is no form-fmodule-file some/path
so we don't need to handle that case.