diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-08-27 22:55:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-08-27 22:55:10 +0000 |
commit | fcee9460c68bfba7eafc29cd41f051ab88d18d4c (patch) | |
tree | 05824557b6cb3c15e8e0cced99d26b19be33a987 | |
parent | 6c1395f62ae1319143b77cf4fc15fe8b744aaf35 (diff) | |
download | bcm5719-llvm-fcee9460c68bfba7eafc29cd41f051ab88d18d4c.tar.gz bcm5719-llvm-fcee9460c68bfba7eafc29cd41f051ab88d18d4c.zip |
Miscellaneous found by inspection with John and Sebastian
llvm-svn: 112315
-rw-r--r-- | clang/include/clang/AST/Decl.h | 9 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 38 |
2 files changed, 22 insertions, 25 deletions
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index cb794ff60a7..407ee3d123d 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -701,11 +701,10 @@ public: bool isFileVarDecl() const { if (getKind() != Decl::Var) return false; - if (const DeclContext *Ctx = getDeclContext()) { - Ctx = Ctx->getLookupContext(); - if (isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx) ) - return true; - } + + if (getDeclContext()->getLookupContext()->isFileContext()) + return true; + if (isStaticDataMember()) return true; diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 122a956cb38..26d49419174 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2627,26 +2627,23 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC, if (!OuterContext->isFunctionOrMethod()) // This rule only applies to block-scope declarations. return false; - else { - DeclContext *PrevOuterContext = PrevDecl->getDeclContext(); - if (PrevOuterContext->isRecord()) - // We found a member function: ignore it. - return false; - else { - // Find the innermost enclosing namespace for the new and - // previous declarations. - while (!OuterContext->isFileContext()) - OuterContext = OuterContext->getParent(); - while (!PrevOuterContext->isFileContext()) - PrevOuterContext = PrevOuterContext->getParent(); - - // The previous declaration is in a different namespace, so it - // isn't the same function. - if (OuterContext->getPrimaryContext() != - PrevOuterContext->getPrimaryContext()) - return false; - } - } + + DeclContext *PrevOuterContext = PrevDecl->getDeclContext(); + if (PrevOuterContext->isRecord()) + // We found a member function: ignore it. + return false; + + // Find the innermost enclosing namespace for the new and + // previous declarations. + while (!OuterContext->isFileContext()) + OuterContext = OuterContext->getParent(); + while (!PrevOuterContext->isFileContext()) + PrevOuterContext = PrevOuterContext->getParent(); + + // The previous declaration is in a different namespace, so it + // isn't the same function. + if (!OuterContext->Equals(PrevOuterContext)) + return false; } return true; @@ -5511,6 +5508,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, PrevDecl = Tag; Previous.clear(); Previous.addDecl(Tag); + Previous.resolveKind(); } } } |