[clang] fix merging of UsingShadowDecl
Previously, when deciding if two UsingShadowDecls where mergeable,
we would incorrectly only look for both pointing to the exact redecla
ration, whereas the correct thing is to look for declarations to the
same entity.
This problem has existed as far back as 2013, introduced in commit
fd8634a09d.
This problem could manifest itself as ODR check false positives when
importing modules.
Fixes: #80252
36 lines
1.1 KiB
C++
36 lines
1.1 KiB
C++
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: cd %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 -I %t %t/A.cppm -emit-module-interface -o %t/A.pcm -verify
|
|
// RUN: %clang_cc1 -std=c++20 -I %t %t/B.cpp -fmodule-file=A=%t/A.pcm -fsyntax-only -verify -ast-dump-all -ast-dump-filter baz | FileCheck %s
|
|
|
|
//--- foo.h
|
|
namespace baz {
|
|
using foo = char;
|
|
using baz::foo;
|
|
}
|
|
|
|
//--- A.cppm
|
|
// expected-no-diagnostics
|
|
module;
|
|
#include "foo.h"
|
|
export module A;
|
|
|
|
//--- B.cpp
|
|
// expected-no-diagnostics
|
|
#include "foo.h"
|
|
import A;
|
|
// Since modules are loaded lazily, force loading by performing a lookup.
|
|
using xxx = baz::foo;
|
|
|
|
// CHECK-LABEL: Dumping baz:
|
|
// CHECK-NEXT: NamespaceDecl 0x[[BAZ_REDECL_ADDR:[^ ]*]] prev 0x[[BAZ_ADDR:[^ ]*]]
|
|
// CHECK: TypeAliasDecl 0x[[ALIAS_REDECL_ADDR:[^ ]*]] prev 0x[[ALIAS_ADDR:[^ ]*]]
|
|
// FIXME: UsingShadowDecl should have been merged
|
|
// CHECK: UsingShadowDecl 0x{{[^ ]*}} prev 0x[[SHADOW_ADDR:[^ ]*]] {{.*}} imported in A.<global> {{.*}} 'foo'
|
|
|
|
// CHECK-LABEL: Dumping baz:
|
|
// CHECK-NEXT: NamespaceDecl 0x[[BAZ_ADDR]] <{{.*}}> line:{{.*}} baz
|
|
// CHECK: UsingShadowDecl 0x[[SHADOW_ADDR]] {{.*}} 'foo'
|