aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-01-09 18:51:29 +0000
committerDouglas Gregor <dgregor@apple.com>2009-01-09 18:51:29 +0000
commita8cc8ce044e5d2589128f0c1a84e586cce743b27 (patch)
tree4adb92ceade9162327c38ca3335c964676b8357f /lib/Sema/SemaDecl.cpp
parent1b95a6546d1f3847da29da0d1e8dc5d77b1a7fbb (diff)
Make sure that ScopedDecls passed to DeclContext::addDecl are added into their lexical context
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61998 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r--lib/Sema/SemaDecl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index d9436ebdc7..ecf6de9d96 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -441,7 +441,13 @@ ScopedDecl *Sema::LazilyCreateBuiltin(IdentifierInfo *II, unsigned bid,
// TUScope is the translation-unit scope to insert this function into.
+ // FIXME: This is hideous. We need to teach PushOnScopeChains to
+ // relate Scopes to DeclContexts, and probably eliminate CurContext
+ // entirely, but we're not there yet.
+ DeclContext *SavedContext = CurContext;
+ CurContext = Context.getTranslationUnitDecl();
PushOnScopeChains(New, TUScope);
+ CurContext = SavedContext;
return New;
}
@@ -2705,6 +2711,8 @@ Sema::DeclTy *Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, DeclTy *D) {
// Introduce our parameters into the function scope
for (unsigned p = 0, NumParams = FD->getNumParams(); p < NumParams; ++p) {
ParmVarDecl *Param = FD->getParamDecl(p);
+ Param->setOwningFunction(FD);
+
// If this has an identifier, add it to the scope stack.
if (Param->getIdentifier())
PushOnScopeChains(Param, FnBodyScope);