diff options
author | Caitlin Sadowski <supertri@google.com> | 2011-09-08 17:42:31 +0000 |
---|---|---|
committer | Caitlin Sadowski <supertri@google.com> | 2011-09-08 17:42:31 +0000 |
commit | ed9d84a2112e2bd56befb5f4fa8fc5bdf71fafa3 (patch) | |
tree | cc1d430044e599baf8afacd324275b752b526383 /lib/Sema | |
parent | eff98fc3561f6b717f6348f04b3f4fe03e934466 (diff) |
Thread safety: added support for function scopes in attribute arguments.
This patch was written by DeLesley Hutchins.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139302 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 23 | ||||
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 8 |
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 251913eb79..10b53f2a81 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -782,6 +782,29 @@ void Sema::ExitDeclaratorContext(Scope *S) { // disappear. } + +void Sema::ActOnReenterFunctionContext(Scope* S, Decl *D) { + FunctionDecl *FD = dyn_cast<FunctionDecl>(D); + if (FunctionTemplateDecl *TFD = dyn_cast_or_null<FunctionTemplateDecl>(D)) { + // We assume that the caller has already called + // ActOnReenterTemplateScope + FD = TFD->getTemplatedDecl(); + } + if (!FD) + return; + + PushDeclContext(S, FD); + for (unsigned P = 0, NumParams = FD->getNumParams(); P < NumParams; ++P) { + ParmVarDecl *Param = FD->getParamDecl(P); + // If the parameter has an identifier, then add it to the scope + if (Param->getIdentifier()) { + S->AddDecl(Param); + IdResolver.AddDecl(Param); + } + } +} + + /// \brief Determine whether we allow overloading of the function /// PrevDecl with another declaration. /// diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 1119866352..a77454e814 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -304,8 +304,11 @@ static bool checkAttrArgsAreLockableObjs(Sema &S, Decl *D, for(unsigned Idx = Sidx; Idx < Attr.getNumArgs(); ++Idx) { Expr *ArgExp = Attr.getArg(Idx); - if (ArgExp->isTypeDependent()) - continue; + if (ArgExp->isTypeDependent()) { + // FIXME -- need to processs this again on template instantiation + Args.push_back(ArgExp); + continue; + } QualType ArgTy = ArgExp->getType(); @@ -390,6 +393,7 @@ static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr, return; if (Arg->isTypeDependent()) + // FIXME: handle attributes with dependent types return; // check that the argument is lockable object |