[cfe-commits] r62245 - in /cfe/trunk: lib/Sema/CMakeLists.txt lib/Sema/IdentifierResolver.h lib/Sema/Sema.h lib/Sema/SemaCXXScopeSpec.cpp lib/Sema/SemaDecl.cpp lib/Sema/SemaDeclCXX.cpp lib/Sema/SemaExpr.cpp lib/Sema/SemaExprCXX.cpp lib/Sema/SemaLookup.cpp test/Parser/cxx-using-directive.cpp test/SemaCXX/qualified-id-lookup.cpp

Douglas Gregor dgregor at apple.com
Wed Jan 14 15:28:49 PST 2009


On Jan 14, 2009, at 3:24 PM, Douglas Gregor wrote:

>
> On Jan 14, 2009, at 3:10 PM, Sebastian Redl wrote:
>
>> Douglas Gregor wrote:
>>> Author: dgregor
>>> Date: Wed Jan 14 16:20:51 2009
>>> New Revision: 62245
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=62245&view=rev
>>> Log:
>>> Refactor name lookup.
>>>
>>> This change refactors and cleans up our handling of name lookup with
>>> LookupDecl. There are several aspects to this refactoring:
>>>
>>>
>>> +/// @brief Determine the result of name lookup.
>>> +Sema::LookupResult::LookupKind Sema::LookupResult::getKind()  
>>> const {
>>> +  switch (StoredKind) {
>>> +  case SingleDecl:
>>> +    return (reinterpret_cast<Decl *>(First) != 0)? Found :  
>>> NotFound;
>>> +
>>> +  case OverloadedDeclFromIdResolver:
>>> +  case OverloadedDeclFromDeclContext:
>>> +    return FoundOverloaded;
>>> +
>>> +  case AmbiguousLookup:
>>> +    return Ambiguous;
>>> +  }
>>> +
>>> +  // We can't get here, but GCC complains nonetheless.
>>> +  return Ambiguous;
>>> +}
>>>
>>
>> I believe our standard way of handling this is by having a default
>> case
>> that asserts.
>>
>> switch (StoredKind) {
>> default: assert(false && "Bad StoredKind");
>
> IIRC, I was getting bogus "function does not return a value" warnings
> from GCC when I've done this.

Nevermind, I have a better reason: if I put in a default clause, then  
I've suppressed the warning that will tell me if I've added an  
enumerator to StoredKind and forgotten to add it here. That's worse  
than having a little dead code.

   - Doug



More information about the cfe-commits mailing list