diff options
author | Richard Trieu <rtrieu@google.com> | 2019-06-22 00:32:19 +0000 |
---|---|---|
committer | Richard Trieu <rtrieu@google.com> | 2019-06-22 00:32:19 +0000 |
commit | 82df97ca8e699bb984046e2dce2d9023189cfcb8 (patch) | |
tree | f744adecc7e4102f6b14121a93a9961cdf570677 /clang/test/Modules | |
parent | 0eb966c8248b290385980ffdad26553a520ace13 (diff) | |
download | bcm5719-llvm-82df97ca8e699bb984046e2dce2d9023189cfcb8.tar.gz bcm5719-llvm-82df97ca8e699bb984046e2dce2d9023189cfcb8.zip |
[ODRHash] Skip some typedef types.
In some cases, a typedef only strips aways a keyword for a type, keeping the
same name as the root record type. This causes some confusion when the type
is defined in one modules but only forward declared in another. Skipping the
typedef and going straight to the record will avoid this issue.
typedef struct S {} S;
S* s; // S is TypedefType here
struct S;
S* s; // S is RecordType here
llvm-svn: 364119
Diffstat (limited to 'clang/test/Modules')
-rw-r--r-- | clang/test/Modules/odr_hash.cpp | 63 |
1 files changed, 62 insertions, 1 deletions
diff --git a/clang/test/Modules/odr_hash.cpp b/clang/test/Modules/odr_hash.cpp index f22a8b8f8a0..ff7cfb3ae7f 100644 --- a/clang/test/Modules/odr_hash.cpp +++ b/clang/test/Modules/odr_hash.cpp @@ -4621,9 +4621,70 @@ struct S2 { #else S2 s2; #endif - } +namespace TypedefStruct { +#if defined(FIRST) +struct T1; +class S1 { + T1* t; +}; +#elif defined(SECOND) +typedef struct T1 {} T1; +class S1 { + T1* t; +}; +#else +S1 s1; +#endif + +#if defined(FIRST) +struct T2; +class S2 { + const T2* t = nullptr; +}; +#elif defined(SECOND) +typedef struct T2 {} T2; +class S2 { + const T2* t = nullptr; +}; +#else +S2 s2; +#endif + +#if defined(FIRST) +struct T3; +class S3 { + T3* const t = nullptr; +}; +#elif defined(SECOND) +typedef struct T3 {} T3; +class S3 { + T3* const t = nullptr; +}; +#else +S3 s3; +#endif + +#if defined(FIRST) +namespace NS4 { +struct T4; +} // namespace NS4 +class S4 { + NS4::T4* t = 0; +}; +#elif defined(SECOND) +namespace NS4 { +typedef struct T4 {} T4; +} // namespace NS4 +class S4 { + NS4::T4* t = 0; +}; +#else +S4 s4; +#endif +} // namespace TypedefStruct + // Keep macros contained to one file. #ifdef FIRST #undef FIRST |