[clang] [clang] ASTContext: flesh out implementation of getCommonNNS (PR #131964)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 19 06:42:35 PDT 2025


================
@@ -13462,13 +13462,114 @@ static ElaboratedTypeKeyword getCommonTypeKeyword(const T *X, const T *Y) {
                                             : ElaboratedTypeKeyword::None;
 }
 
+static NestedNameSpecifier *getCommonNNS(ASTContext &Ctx,
+                                         NestedNameSpecifier *X,
+                                         NestedNameSpecifier *Y, bool IsSame) {
+  if (X == Y)
+    return X;
+
+  NestedNameSpecifier *Canon = Ctx.getCanonicalNestedNameSpecifier(X);
+  if (Canon != Ctx.getCanonicalNestedNameSpecifier(Y)) {
+    assert(!IsSame && "Should be the same NestedNameSpecifier");
+    return nullptr;
+  }
+
+  NestedNameSpecifier *R = nullptr;
+  switch (auto KX = X->getKind(), KY = Y->getKind(); KX) {
----------------
erichkeane wrote:

Also, i probably prefer this not be in the switch `init` section and instead be on the lines above.  This was actually a bit jarring (and I actually thought this was a `for` loop on my first look).

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


More information about the cfe-commits mailing list