For style guides forbid "using" declarations for namespaces like "std".
With this new config option, AddUsing can be selectively disabled on
those.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice!
clang-tools-extra/clangd/Config.h | ||
---|---|---|
66 | describe elements more precisely? | |
clang-tools-extra/clangd/ConfigCompile.cpp | ||
215 | this is a good place to validate and/or normalize (leading/trailing ::) | |
clang-tools-extra/clangd/ConfigFragment.h | ||
167 | Can we describe this positively first? Namespaces whose members should be fully-qualified, rather than via using declarations or directives. | |
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp | ||
197 | validate it's a namespace, and then call printNamespaceScope (AST.h)? This handles the right spelling of anonymous/inline NSes. | |
208 | we should do this at config compile time instead I think - conceptually simpler if we store normalized data | |
210 | slightly silly, but can we take a stringref, consume Banned, and verify that the result is empty or begins with ::? Avoids a silly string copy, explicitly handles the sub-namespace case, and is just more typical of the string code we write. |
Thanks!
Can we add a simple test to TweakTests (I should really split up that file) and to ConfigCompileTests?
(BTW, do you think we should merge Config{Compile,YAML}Tests?
clang-tools-extra/clangd/Config.h | ||
---|---|---|
70 | should just be "without leading ::" now I think? | |
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp | ||
200 | not needed - printNamespaceScope never starts with :: | |
201 | inlining this into the if (consume_front(Banned) && consume_front(::)) might be clearer, up to you |
addressed review comments
clang-tools-extra/clangd/Config.h | ||
---|---|---|
70 | What I was trying to say here is that both ::foo::bar and foo::bar are allowed, but: using foo; bar is not. Basically I'm trying to explain that what we mean by fully qualified is the no-using-shortcuts, not always-start-with-:: This isn't about what's stored in the vector, but rather what this options means. |
describe elements more precisely?
They are namespaces with/without leading/trailing ::, and sub-namespaces are implicitly included.