Greetings everyone,
I have an problem with a custom clang-tidy check that looks for “forbidden” using namespace
directives (identical to the google-build-namespaces
check, but with configuration options for allowing certain namespaces or allowing the directive inside a function). The diagnostic message that identifies where the using namespace
is occurring is reported correctly. However, the fixit insertion hints I provide for prepending type and reference expressions with the imported namespace are not reported. In other words, I expect to see a fixit hint indicating that cout
should be renamed std::cout
since using namespace std;
will be removed; none of those hints are being displayed.
I’ve ensured the insertion locations are valid and not inside macros. I think I know what’s happening, but I haven’t traced the code path into Clang far enough to confirm it: because the fixit insertion locations are not contained by the initial range reported to diag
(the actual using namespace
directive source range), the hints are being discarded. I could understand this happening since changing code outside of the “problem” range could be construed as an out-of-scope conflict. (“Why are you changing unrelated code?”)
Does this sound like what’s happening, or is it likely there is something else going on? I know this can be a pain to diagnose without code – my apologies for that up front.