On Mon, Aug 20, 2012 at 2:32 PM, DeLesley Hutchins <[email protected]>wrote:
> Author: delesley > Date: Mon Aug 20 16:32:18 2012 > New Revision: 162229 > > URL: http://llvm.org/viewvc/llvm-project?rev=162229&view=rev > Log: > Thread-safety analysis: fix scoping issues related to 'this', including an > ICE in friend functions. > > Modified: > cfe/trunk/lib/Parse/ParseDecl.cpp > cfe/trunk/test/SemaCXX/warn-thread-safety-parsing.cpp > > Modified: cfe/trunk/lib/Parse/ParseDecl.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=162229&r1=162228&r2=162229&view=diff > > ============================================================================== > --- cfe/trunk/lib/Parse/ParseDecl.cpp (original) > +++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Aug 20 16:32:18 2012 > @@ -851,10 +851,6 @@ > Actions.ActOnStartDelayedMemberDeclarations(getCurScope(), > Class.TagOrTemplate); > if (!Class.LateParsedDeclarations.empty()) { > - // Allow 'this' within late-parsed attributes. > - Sema::CXXThisScopeRAII ThisScope(Actions, Class.TagOrTemplate, > - /*TypeQuals=*/0); > - > for (unsigned i = 0, ni = Class.LateParsedDeclarations.size(); i < > ni; ++i){ > Class.LateParsedDeclarations[i]->ParseLexedAttributes(); > } > @@ -904,34 +900,43 @@ > ParsedAttributes Attrs(AttrFactory); > SourceLocation endLoc; > > - if (LA.Decls.size() == 1) { > + if (LA.Decls.size() > 0) { > Decl *D = LA.Decls[0]; > + NamedDecl *ND = dyn_cast<NamedDecl>(D); > + RecordDecl *RD = dyn_cast_or_null<RecordDecl>(D->getDeclContext()); > > - // If the Decl is templatized, add template parameters to scope. > - bool HasTemplateScope = EnterScope && D->isTemplateDecl(); > - ParseScope TempScope(this, Scope::TemplateParamScope, > HasTemplateScope); > - if (HasTemplateScope) > - Actions.ActOnReenterTemplateScope(Actions.CurScope, D); > - > - // If the Decl is on a function, add function parameters to the scope. > - bool HasFunctionScope = EnterScope && > D->isFunctionOrFunctionTemplate(); > - ParseScope FnScope(this, Scope::FnScope|Scope::DeclScope, > HasFunctionScope); > - if (HasFunctionScope) > - Actions.ActOnReenterFunctionContext(Actions.CurScope, D); > - > - ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc); > - > - if (HasFunctionScope) { > - Actions.ActOnExitFunctionContext(); > - FnScope.Exit(); // Pop scope, and remove Decls from IdResolver > - } > - if (HasTemplateScope) { > - TempScope.Exit(); > - } > - } else if (LA.Decls.size() > 0) { > - // If there are multiple decls, then the decl cannot be within the > - // function scope. > - ParseGNUAttributeArgs(&LA.AttrName, LA.AttrNameLoc, Attrs, &endLoc); > + // Allow 'this' within late-parsed attributes. > + Sema::CXXThisScopeRAII ThisScope(Actions, RD, > + /*TypeQuals=*/0, > I don't know whether you care about this for the thread safety annotations, but I believe you're now in a position where you can get the type qualifiers "right" -- if the attribute is attached to a CXXMethodDecl, you can use the cv-qualifiers specified on that function declaration in the type of 'this'.
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
