[clang-tools-extra] [clangd] Avoid C++ name qualification in C (PR #242500)

James Cowsert via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 24 17:51:44 PST 2026


================
@@ -106,6 +106,9 @@ std::string getQualification(ASTContext &Context,
                              const DeclContext *DestContext,
                              const DeclContext *SourceContext,
                              llvm::function_ref<bool(const Decl *)> IsVisible) {
+
+  if (!Context.getLangOpts().CPlusPlus)
+    return "";
----------------
J-Cowsert wrote:

I'm considering two options to avoid the unnecessary work.

1. Move the early returns to the start of both public `getQualification' helpers.

2. put the language check in `PopulateSwitch::apply()`, so it only calls getQualification() in C++ and restore the helpers previous behavior.

Is handling C part of the helpers’ responsibility, or should callers decide when qualification applies? How would you approach deciding between these two options? I’d appreciate hearing what you’d look at and what would make you prefer one approach over the other.


https://github.com/llvm/llvm-project/pull/242500


More information about the cfe-commits mailing list