@@ -338,7 +338,8 @@ const NamedDecl *lookupSiblingWithinEnclosingScope(ASTContext &Ctx,
338
338
for (const auto &Child : DS->getDeclGroup ())
339
339
if (const auto *ND = dyn_cast<NamedDecl>(Child))
340
340
if (ND != &RenamedDecl && ND->getDeclName ().isIdentifier () &&
341
- ND->getName () == Name)
341
+ ND->getName () == Name &&
342
+ ND->getIdentifierNamespace () & RenamedDecl.getIdentifierNamespace ())
342
343
return ND;
343
344
return nullptr ;
344
345
};
@@ -380,7 +381,9 @@ const NamedDecl *lookupSiblingWithinEnclosingScope(ASTContext &Ctx,
380
381
// Also check if there is a name collision with function arguments.
381
382
if (const auto *Function = ScopeParent->get <FunctionDecl>())
382
383
for (const auto *Parameter : Function->parameters ())
383
- if (Parameter->getName () == NewName)
384
+ if (Parameter->getName () == NewName &&
385
+ Parameter->getIdentifierNamespace () &
386
+ RenamedDecl.getIdentifierNamespace ())
384
387
return Parameter;
385
388
return nullptr ;
386
389
}
@@ -405,7 +408,9 @@ const NamedDecl *lookupSiblingWithinEnclosingScope(ASTContext &Ctx,
405
408
if (const auto *EnclosingFunction = Parent->get <FunctionDecl>()) {
406
409
// Check for conflicts with other arguments.
407
410
for (const auto *Parameter : EnclosingFunction->parameters ())
408
- if (Parameter != &RenamedDecl && Parameter->getName () == NewName)
411
+ if (Parameter != &RenamedDecl && Parameter->getName () == NewName &&
412
+ Parameter->getIdentifierNamespace () &
413
+ RenamedDecl.getIdentifierNamespace ())
409
414
return Parameter;
410
415
// FIXME: We don't modify all references to function parameters when
411
416
// renaming from forward declaration now, so using a name colliding with
@@ -450,7 +455,8 @@ const NamedDecl *lookupSiblingsWithinContext(ASTContext &Ctx,
450
455
}
451
456
// Lookup may contain the RenameDecl itself, exclude it.
452
457
for (const auto *D : LookupResult)
453
- if (D->getCanonicalDecl () != RenamedDecl.getCanonicalDecl ())
458
+ if (D->getCanonicalDecl () != RenamedDecl.getCanonicalDecl () &&
459
+ D->getIdentifierNamespace () & RenamedDecl.getIdentifierNamespace ())
454
460
return D;
455
461
return nullptr ;
456
462
}
0 commit comments