-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[clang] incorrect merging of UsingShadowDecl #80252
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@llvm/issue-subscribers-clang-modules Author: Matheus Izvekov (mizvekov)
When merging imported modules, equivalent UsingShadowDecls from the TU and from the module would not be merged, resulting in them becoming different entities, instead of redeclarations.
A simple reproducer would be:
Building this with: This would result in the following AST:
The first UsingShadowDecl should have been a redeclaration of the second one. You would expect:
This was originally reduced from this example that manifested itself as an ODR violation in the global module fragment:
And this compilation would result in an ODR false positive, where the definitions for the bar constructor don't match due to different parameters. This failure stopped happening when we merged the patch to disable the GMF ODR check. This had been further reduced from a similar example with pure inclusion of libc++ headers, on MSVC platform. |
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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
FYI @ChuanqiXu9 |
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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
FYI since you are filing this issue to track your progress, you can self-add the "confirmed" label. |
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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
[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 fd8634a. This problem could manifest itself as ODR check false positives when importing modules. Fixes: #80252
When merging imported modules, equivalent UsingShadowDecls from the TU and from the module would not be merged, resulting in them becoming different entities, instead of redeclarations.
A simple reproducer would be:
foo.h
A.cppm
B.cpp
Building this with:
-cc1 -std=c++20 -emit-module-interface -o A.pcm A.cppm
-cc1 -std=c++20 -fmodule-file=A=A.pcm -fsyntax-only -ast-dump-all -ast-dump-filter baz C.cpp
This would result in the following AST:
The first UsingShadowDecl should have been a redeclaration of the second one.
You would expect:
This was originally reduced from this example that manifested itself as an ODR violation in the global module fragment:
foo.h
bar.h
A.cppm
B.cppm
C.cpp
And this compilation would result in an ODR false positive, where the definitions for the bar constructor don't match due to different parameters. This failure stopped happening when we merged the patch to disable the GMF ODR check.
This had been further reduced from a similar example with pure inclusion of libc++ headers, on MSVC platform.
s/foo.h/stddef.h
s/bar.h/locale
The text was updated successfully, but these errors were encountered: