-
Notifications
You must be signed in to change notification settings - Fork 22
fix: reproducible standard library for clang-cl #997
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 |
---|---|---|
|
@@ -114,9 +114,15 @@ handleFile( | |
|
||
// Create an adjusted MrDocsDatabase | ||
auto parentDir = files::getParentDir(filePath); | ||
bool const is_clang_cl = | ||
#if defined(WIN32) | ||
true; | ||
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. This is an arbitrary compile value for a runtime condition. We just need to make sure the include paths we want are getting there. One easy way to test this is to define some macro or something in our libc stubs and check (maybe just static assert) if that's what we're getting in the libcxx.cpp test or some similar new test for libc stubs, or just for that. Testing the same code with different is_clang_cl in the MrDocsCompilationDatabase is a bit harder, and we'd have to think about it. But that looks more like a unit test than a golden test. It should go into the unit tests, and we check if the commands have the properties we expect from them after MrDocsCompilationDatabase normalizes them. 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 purpose of this change is to more closely match the actual user experience. It's a good idea to make the tests more robust. While we own and can easily modify the libc stubs, there is no test for the system-libc option. There is a test for the system-stdlib option, but those headers come directly from llvm-project and modifying them in place is questionable. We can add an extra file somewhere in build/share, include this location as an additional system-stdlib location, and check for it with The existing libcxx test check attempts to include |
||
#else | ||
false; | ||
#endif | ||
std::unordered_map<std::string, std::vector<std::string>> defaultIncludePaths; | ||
MrDocsCompilationDatabase compilations( | ||
llvm::StringRef(parentDir), SingleFileDB(filePath), config, defaultIncludePaths); | ||
llvm::StringRef(parentDir), SingleFileDB(filePath, is_clang_cl), config, defaultIncludePaths); | ||
|
||
report::debug("Building Corpus", filePath); | ||
auto corpus = CorpusImpl::build(config, compilations); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
This path is unnecessary. is_clang_cl would be generating behavior that's externally functionally equivalent for both true and false.
I know the point here is to make different values arrive at MrDocsCompilationDatabase, but that's not the role of SingleFileDB (which we might want to use independently later and not have to maintain both paths).
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.
This is an attempt to represent a compilation database generated by cmake on windows.
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 understand that. Besides the obvious problem that clang-cl is not the only compiler on Windows, that's not the role of this class, and everything else I said above. This is not a test class, and you're including a change the class doesn't need. I left another comment explaining how you can test the change you actually want to test.
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 don't follow, clang is not the only compiler on Windows/Linux either.
I agree that none of these hardcoded values belong in a class that represents a single file compilation database.