diff options
author | Devang Patel <dpatel@apple.com> | 2010-04-24 00:40:35 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2010-04-24 00:40:35 +0000 |
commit | f0bf4d554f2513cbb4bec952c81ced59279ad91e (patch) | |
tree | a55e670cb3171f2439953d4edd84ce22da15ab09 /lib/Sema/SemaLookup.cpp | |
parent | 8a4377697161c5087e27cc40d6e0682f0cd1fa20 (diff) |
Revert r102215. This causes clang crash while compiling a test case from gdb testsuite.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102224 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaLookup.cpp')
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 0609eef3c9..a7a1084d31 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -193,6 +193,37 @@ namespace { }; } +static bool IsAcceptableIDNS(NamedDecl *D, unsigned IDNS) { + return D->isInIdentifierNamespace(IDNS); +} + +static bool IsAcceptableOperatorName(NamedDecl *D, unsigned IDNS) { + return D->isInIdentifierNamespace(IDNS) && + !D->getDeclContext()->isRecord(); +} + +/// Gets the default result filter for the given lookup. +static inline +LookupResult::ResultFilter getResultFilter(Sema::LookupNameKind NameKind) { + switch (NameKind) { + case Sema::LookupOrdinaryName: + case Sema::LookupTagName: + case Sema::LookupMemberName: + case Sema::LookupRedeclarationWithLinkage: // FIXME: check linkage, scoping + case Sema::LookupUsingDeclName: + case Sema::LookupObjCProtocolName: + case Sema::LookupNestedNameSpecifierName: + case Sema::LookupNamespaceName: + return &IsAcceptableIDNS; + + case Sema::LookupOperatorName: + return &IsAcceptableOperatorName; + } + + llvm_unreachable("unkknown lookup kind"); + return 0; +} + // Retrieve the set of identifier namespaces that correspond to a // specific kind of name lookup. static inline unsigned getIDNS(Sema::LookupNameKind NameKind, @@ -201,6 +232,7 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind, unsigned IDNS = 0; switch (NameKind) { case Sema::LookupOrdinaryName: + case Sema::LookupOperatorName: case Sema::LookupRedeclarationWithLinkage: IDNS = Decl::IDNS_Ordinary; if (CPlusPlus) { @@ -209,13 +241,6 @@ static inline unsigned getIDNS(Sema::LookupNameKind NameKind, } break; - case Sema::LookupOperatorName: - // Operator lookup is its own crazy thing; it is not the same - // as (e.g.) looking up an operator name for redeclaration. - assert(!Redeclaration && "cannot do redeclaration operator lookup"); - IDNS = Decl::IDNS_NonMemberOperator; - break; - case Sema::LookupTagName: if (CPlusPlus) { IDNS = Decl::IDNS_Type; @@ -262,6 +287,7 @@ void LookupResult::configure() { IDNS = getIDNS(LookupKind, SemaRef.getLangOptions().CPlusPlus, isForRedeclaration()); + IsAcceptableFn = getResultFilter(LookupKind); // If we're looking for one of the allocation or deallocation // operators, make sure that the implicitly-declared new and delete |