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 | ||
---|---|---|
30 | using a map here seems like an overkill, we have just 2 elements, I'd just use two separate variables (CMapping, and CXXMapping) | |
123 | nit: just for (Lang Language: {Lang::C, Lang::CXX}) or two statements initilize(Lang::C); and initialize(Lang::CXX);. | |
212 | Do we need the ensureInitialized() here? looks like no needed, we have called it in the Recognizer constructor, | |
233 | nit: just use LangOpts.CPlusPlus to check the language. |
Thanks for the comments!
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
30 | 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. | |
123 | 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. | |
212 | you're right, not needed. | |
233 | There's LangStandard::isCPlusPlus method that I've just discovered. That's probably even better. |
clang/lib/Tooling/Inclusions/Stdlib/StandardLibrary.cpp | ||
---|---|---|
30 | 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]; | |
233 | 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 | ||
138 | nit: just EXPECT_FALSE(stdlib::Symbol::named("", "int16_t"))), following the existing pattern L46. | |
145 | 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, 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 | ||
---|---|---|
30 | 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)