File tree Expand file tree Collapse file tree 6 files changed +26
-19
lines changed Expand file tree Collapse file tree 6 files changed +26
-19
lines changed Original file line number Diff line number Diff line change @@ -6016,18 +6016,17 @@ inline ObjCProtocolDecl **ObjCTypeParamType::getProtocolStorageImpl() {
6016
6016
class ObjCInterfaceType : public ObjCObjectType {
6017
6017
friend class ASTContext ; // ASTContext creates these.
6018
6018
friend class ASTReader ;
6019
- friend class ObjCInterfaceDecl ;
6020
6019
template <class T > friend class serialization ::AbstractTypeReader;
6021
6020
6022
- mutable ObjCInterfaceDecl *Decl;
6021
+ ObjCInterfaceDecl *Decl;
6023
6022
6024
6023
ObjCInterfaceType (const ObjCInterfaceDecl *D)
6025
6024
: ObjCObjectType(Nonce_ObjCInterface),
6026
6025
Decl (const_cast <ObjCInterfaceDecl*>(D)) {}
6027
6026
6028
6027
public:
6029
6028
// / Get the declaration of this interface.
6030
- ObjCInterfaceDecl *getDecl () const { return Decl; }
6029
+ ObjCInterfaceDecl *getDecl () const ;
6031
6030
6032
6031
bool isSugared () const { return false ; }
6033
6032
QualType desugar () const { return QualType (this , 0 ); }
Original file line number Diff line number Diff line change @@ -603,10 +603,6 @@ void ObjCInterfaceDecl::allocateDefinitionData() {
603
603
assert (!hasDefinition () && " ObjC class already has a definition" );
604
604
Data.setPointer (new (getASTContext ()) DefinitionData ());
605
605
Data.getPointer ()->Definition = this ;
606
-
607
- // Make the type point at the definition, now that we have one.
608
- if (TypeForDecl)
609
- cast<ObjCInterfaceType>(TypeForDecl)->Decl = this ;
610
606
}
611
607
612
608
void ObjCInterfaceDecl::startDefinition () {
Original file line number Diff line number Diff line change @@ -821,6 +821,13 @@ QualType ObjCObjectType::stripObjCKindOfTypeAndQuals(
821
821
/* isKindOf=*/ false );
822
822
}
823
823
824
+ ObjCInterfaceDecl *ObjCInterfaceType::getDecl () const {
825
+ ObjCInterfaceDecl *Canon = Decl->getCanonicalDecl ();
826
+ if (ObjCInterfaceDecl *Def = Canon->getDefinition ())
827
+ return Def;
828
+ return Canon;
829
+ }
830
+
824
831
const ObjCObjectPointerType *ObjCObjectPointerType::stripObjCKindOfTypeAndQuals (
825
832
const ASTContext &ctx) const {
826
833
if (!isKindOfType () && qual_empty ())
Original file line number Diff line number Diff line change @@ -5323,11 +5323,8 @@ static NamedDecl *getDefinitionToImport(NamedDecl *D) {
5323
5323
return FD->getDefinition ();
5324
5324
if (TagDecl *TD = dyn_cast<TagDecl>(D))
5325
5325
return TD->getDefinition ();
5326
- // The first definition for this ObjCInterfaceDecl might be in the TU
5327
- // and not associated with any module. Use the one we know to be complete
5328
- // and have just seen in a module.
5329
5326
if (ObjCInterfaceDecl *ID = dyn_cast<ObjCInterfaceDecl>(D))
5330
- return ID;
5327
+ return ID-> getDefinition () ;
5331
5328
if (ObjCProtocolDecl *PD = dyn_cast<ObjCProtocolDecl>(D))
5332
5329
return PD->getDefinition ();
5333
5330
if (TemplateDecl *TD = dyn_cast<TemplateDecl>(D))
Original file line number Diff line number Diff line change 1
1
// RUN: rm -rf %t
2
- // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4
3
- // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4
4
- // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4
5
- // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4
2
+ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_1 -DUSE_2 -DUSE_3 -DUSE_4 -DUSE_5
3
+ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_2 -DUSE_3 -DUSE_4 -DUSE_5
4
+ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_3 -DUSE_4 -DUSE_5
5
+ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_4 -DUSE_5
6
+ // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fobjc-arc -I %S/Inputs -fmodules-cache-path=%t %s -verify -DUSE_5
6
7
7
8
// expected-note@Inputs/def.h:5 0-1{{here}}
9
+ // expected-note@Inputs/def.h:11 0-1{{here}}
8
10
// expected-note@Inputs/def.h:16 0-1{{here}}
9
11
// expected-note@Inputs/def-include.h:11 0-1{{here}}
10
12
@@ -51,11 +53,17 @@ void testB() {
51
53
}
52
54
53
55
void testDef () {
56
+ #ifdef USE_4
54
57
[def defMethod ];
58
+ #ifndef USED
59
+ // expected-error@-2{{definition of 'Def' must be imported from module 'decldef.Def' before it is required}}
60
+ #define USED
61
+ #endif
62
+ #endif
55
63
}
56
64
57
65
void testDef2 () {
58
- #ifdef USE_4
66
+ #ifdef USE_5
59
67
def2->func ();
60
68
def3->func ();
61
69
#ifndef USED
Original file line number Diff line number Diff line change 1
1
// RUN: rm -rf %t
2
2
// RUN: %clang_cc1 %s -fsyntax-only -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F%S/Inputs/interface-diagnose-missing-import -verify
3
+ // expected-no-diagnostics
3
4
@interface Buggy
4
5
@end
5
6
6
7
@import Foo.Bar;
7
8
8
- @interface Buggy (MyExt) // expected-error {{definition of 'Buggy' must be imported from module 'Foo' before it is required}}
9
+ // No diagnostic for inaccessible 'Buggy' definition because we have another definition right in this file.
10
+ @interface Buggy (MyExt)
9
11
@end
10
-
11
- // expected-note@Foo/RandoPriv.h:3{{definition here is not reachable}}
You can’t perform that action at this time.
0 commit comments