[cfe-commits] r141334 - in /cfe/trunk: include/clang/Parse/Parser.h include/clang/Sema/Sema.h lib/Parse/ParseObjc.cpp lib/Sema/Sema.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclAttr.cpp lib/Sema/SemaDeclObjC.cpp lib/Sema/SemaExpr.cpp test/SemaObjC/attr-deprecated.m test/SemaObjC/class-unavail-warning.m

Argyrios Kyrtzidis kyrtzidis at apple.com
Thu Oct 6 17:55:32 PDT 2011


On Oct 6, 2011, at 5:28 PM, Fariborz Jahanian wrote:

> 
> On Oct 6, 2011, at 4:23 PM, Argyrios Kyrtzidis wrote:
> 
>> Author: akirtzidis
>> Date: Thu Oct  6 18:23:20 2011
>> New Revision: 141334
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=141334&view=rev
>> Log:
>> When using an unavailable/deprecated interface Foo inside Foo's interface/implementation
>> don't emit unavailable errors.
>> 
>> Modified:
>>   cfe/trunk/include/clang/Parse/Parser.h
>>   cfe/trunk/include/clang/Sema/Sema.h
>>   cfe/trunk/lib/Parse/ParseObjc.cpp
>>   cfe/trunk/lib/Sema/Sema.cpp
>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>   cfe/trunk/lib/Sema/SemaDeclAttr.cpp
>>   cfe/trunk/lib/Sema/SemaDeclObjC.cpp
>>   cfe/trunk/lib/Sema/SemaExpr.cpp
>>   cfe/trunk/test/SemaObjC/attr-deprecated.m
>>   cfe/trunk/test/SemaObjC/class-unavail-warning.m
>> 
>> Modified: cfe/trunk/include/clang/Parse/Parser.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Parser.h?rev=141334&r1=141333&r2=141334&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Parse/Parser.h (original)
>> +++ cfe/trunk/include/clang/Parse/Parser.h Thu Oct  6 18:23:20 2011
>> @@ -520,11 +520,11 @@
>>    explicit ObjCDeclContextSwitch(Parser &p) : P(p), 
>>               DC(p.getObjCDeclContext()) {
>>      if (DC)
>> -        P.Actions.ActOnObjCContainerFinishDefinition();
>> +        P.Actions.ActOnObjCTemporaryExitContainerContext();
>>    }
>>    ~ObjCDeclContextSwitch() {
>>      if (DC)
>> -        P.Actions.ActOnObjCContainerStartDefinition(DC);
>> +        P.Actions.ActOnObjCReenterContainerContext();
>>    }
>>  };
>> 
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=141334&r1=141333&r2=141334&view=diff
>> ==============================================================================
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Oct  6 18:23:20 2011
>> @@ -202,6 +202,10 @@
>>  /// CurContext - This is the current declaration context of parsing.
>>  DeclContext *CurContext;
>> 
>> +  /// \brief Generally null except when we temporarily switch decl contexts,
>> +  /// like in \see ActOnObjCTemporaryExitContainerContext.
>> +  DeclContext *OriginalLexicalContext;
>> +
>>  /// VAListTagName - The declaration name corresponding to __va_list_tag.
>>  /// This is used as part of a hack to omit that class from ADL results.
>>  DeclarationName VAListTagName;
>> @@ -1224,7 +1228,7 @@
>>  /// struct, or union).
>>  void ActOnTagStartDefinition(Scope *S, Decl *TagDecl);
>> 
>> -  void ActOnObjCContainerStartDefinition(Decl *IDecl);
>> +  Decl *ActOnObjCContainerStartDefinition(Decl *IDecl);
>> 
>>  /// ActOnStartCXXMemberDeclarations - Invoked when we have parsed a
>>  /// C++ record definition's base-specifiers clause and are starting its
>> @@ -1240,6 +1244,13 @@
>> 
>>  void ActOnObjCContainerFinishDefinition();
>> 
>> +  /// \brief Invoked when we must temporarily exit the objective-c container
>> +  /// scope for parsing/looking-up C constructs.
>> +  ///
>> +  /// Must be followed by a call to \see ActOnObjCReenterContainerContext
>> +  void ActOnObjCTemporaryExitContainerContext();
>> +  void ActOnObjCReenterContainerContext();
>> +
>>  /// ActOnTagDefinitionError - Invoked when there was an unrecoverable
>>  /// error parsing the definition of a tag.
>>  void ActOnTagDefinitionError(Scope *S, Decl *TagDecl);
>> @@ -6150,6 +6161,10 @@
>>  Scope *getCurScope() const { return CurScope; }
>> 
>>  Decl *getObjCDeclContext() const;
>> +
>> +  DeclContext *getCurLexicalContext() const {
>> +    return OriginalLexicalContext ? OriginalLexicalContext : CurContext;
>> +  }
>> };
>> 
>> /// \brief RAII object that enters a new expression evaluation context.
>> 
>> Modified: cfe/trunk/lib/Parse/ParseObjc.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseObjc.cpp?rev=141334&r1=141333&r2=141334&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Parse/ParseObjc.cpp (original)
>> +++ cfe/trunk/lib/Parse/ParseObjc.cpp Thu Oct  6 18:23:20 2011
>> @@ -336,7 +336,6 @@
>>  tok::ObjCKeywordKind MethodImplKind = tok::objc_not_keyword;
>> 
>>  SourceRange AtEnd;
>> -  Actions.ActOnObjCContainerStartDefinition(CDecl);
> 
> Here do you now push this context? 
>> 
>>  while (1) {
>>    // If this is a method prototype, parse it.
>> @@ -1195,6 +1194,7 @@
>>  SmallVector<Decl *, 32> AllIvarDecls;
>> 
>>  ParseScope ClassScope(this, Scope::DeclScope|Scope::ClassScope);
>> +  ObjCDeclContextSwitch ObjCDC(*this);
>> 
>>  SourceLocation LBraceLoc = ConsumeBrace(); // the "{"
>> 
>> @@ -1441,7 +1441,6 @@
>>                                    atLoc, nameId, nameLoc, categoryId,
>>                                    categoryLoc);
>> 
>> -    Actions.ActOnObjCContainerStartDefinition(ImplCatType);
> 
> And this?
> 
>>    ObjCImpDecl = ImplCatType;
>>    PendingObjCImpDecl.push_back(ObjCImpDecl);
>>    return 0;
>> @@ -1466,7 +1465,6 @@
>>  if (Tok.is(tok::l_brace)) // we have ivars
>>    ParseObjCClassInstanceVariables(ImplClsType, tok::objc_private, atLoc);
>> 
>> -  Actions.ActOnObjCContainerStartDefinition(ImplClsType);
> And this?
> 

Pushing context moved inside Sema, the context is pushed now by:

ActOnStartCategoryInterface / ActOnStartCategoryImplementation
ActOnStartClassInterface / ActOnStartClassImplementation
ActOnStartProtocolInterface

then it gets popped by

ActOnAtEnd


> - Fariborz
> 
> 




More information about the cfe-commits mailing list