Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can you add some tests in StandardLibraryTest.cpp?
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
31 | using a map here seems like an overkill, we have just 2 elements, I'd just use two separate variables (CMapping, and CXXMapping) | |
100 | nit: just for (Lang Language: {Lang::C, Lang::CXX}) or two statements initilize(Lang::C); and initialize(Lang::CXX);. | |
164 | Do we need the ensureInitialized() here? looks like no needed, we have called it in the Recognizer constructor, | |
188 | nit: just use LangOpts.CPlusPlus to check the language. |
Thanks for the comments!
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
31 | what about the design idea that we might potentially want to extend this to multiple standards etc.? The idea is that it's extensible to ObjC, OpenCL... and so on and so forth, as has been discussed offline. | |
100 | yes, same argument as above. I remember extensive discussions about the idea that we might want to extend this to multiple language versions etc. in the future. | |
164 | you're right, not needed. | |
188 | There's LangStandard::isCPlusPlus method that I've just discovered. That's probably even better. |
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
31 | I think having a generic Lang enum structure is sufficient for the future extension, and I don't think we're going to add other languages in the foreseeable future (that's why I value the simple implementation at the beginning). But you're right, getting the implementation right is probably a good idea. I'd like to remove the DenseMap, just use a raw array, something like below should work enum Lang { C = 0, CXX, LastValue = CXX, }; // access by e.g. LanguageMappings[static_cast<unsigned>(Lang::C)]. static SymbolHeaderMapping* LanguageMappings[static_cast<unsigned>(Lang::LastValue) + 1]; | |
188 | sorry if I was not clearer -- there is a bit CPlusPlus in the LangOptions which already does the equivalent thing (see https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/LangOptions.cpp#L107). So we can just use if (D->getLangOpts().CPlusPlus). | |
clang/unittests/Tooling/StandardLibraryTest.cpp | ||
115 ↗ | (On Diff #493918) | nit: just EXPECT_FALSE(stdlib::Symbol::named("", "int16_t"))), following the existing pattern L46. |
122 ↗ | (On Diff #493918) | The existing TEST(StdlibTest, All) test seems like a good umbrella for the this test and the above test, how about moving them to the All test? |
Thanks for the comments!
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
31 | Ok, this will need some casting, but I don't have a strong opinion. | |
188 | Ah ok, thanks. | |
clang/unittests/Tooling/StandardLibraryTest.cpp | ||
115 ↗ | (On Diff #493918) | Right, thanks. |
122 ↗ | (On Diff #493918) | Ok, I've moved everything to existing test cases. |
Thanks, this looks good to me!
This requires some work to rebase for https://github.com/llvm/llvm-project/commit/e1aaa314a46cd303019da117bfd330611d5b7a84, I will rebase it and land it for you.
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
31 | yeah, it is the sad bit, but I think it is OK. |
using a map here seems like an overkill, we have just 2 elements, I'd just use two separate variables (CMapping, and CXXMapping)