PATCH: Semantic analysis and representation of C++ base classes

This patch adds the missing semantic analysis and representation for
C++ base classes. This does a couple of related things:

  - BaseClassDecl represents a base class of a RecordDecl

  - Sema::ActOnBaseSpecifiers attaches the base specifiers to a
RecordDecl and checks that there are no redundant direct base classes.

  - Action::isTypeName now has a new argument, IgnoreNonTypes, which
instructs name lookup to do exactly that. It's needed when looking up
base class names (see C++ [class.derived]p2), e.g.,

    class A { };

    void foo(int A) {
      class B : A { }; // okay: we find class A, not the parameter A.
    }

    As part of this, there's a new IdentifierNamespace enumerator
called IDNS_Ignore_nontypes, which tells the IdentifierResolver to
ignore non-type names. This means that IdentifierNamespace is becoming
much more like a set of flags dictating name lookup rules rather than
the 4 C namespaces it started at. Expect more movement in this
direction as Clang gets more C++-specific name lookup behavior.

  - Doug

clang-inherit.patch (26.7 KB)

This patch adds the missing semantic analysis and representation for
C++ base classes.

Nice!

   As part of this, there's a new IdentifierNamespace enumerator
called IDNS_Ignore_nontypes, which tells the IdentifierResolver to
ignore non-type names. This means that IdentifierNamespace is becoming
much more like a set of flags dictating name lookup rules rather than
the 4 C namespaces it started at. Expect more movement in this
direction as Clang gets more C++-specific name lookup behavior.

Ok, that makes sense to me. As its capabilities grow, we can always refactor it (again!) in the future.

Some comments:

+++ include/clang/AST/Decl.h (working copy)
@@ -15,6 +15,7 @@
  #define LLVM_CLANG_AST_DECL_H

  #include "clang/AST/DeclBase.h"
+#include "clang/Parse/AccessSpecifier.h"

This is a layering violation. The AST library should not depend on the Parser specific structures. It is up to Sema to translate parser versions of these data structures into something permanent that lives in the AST. The logic here is that we want [de]serialization to be able to construct ASTs without going through the parser, and enforcing the layering helps ensure there is a clean way to produce the ASTs. Also, the obvious solution of moving the enum to the AST headers won't work either, as the parser is not allowed to know about ASTs.

This comes up in a variety of places, with different levels of weirdness. For example, attributes and decl specs are parsed into a temporary structure and then sema moves them to a more permanent one. ObjC has a similar issue with its ObjCDeclSpec enums. I think the best way to handle this is to have a switch statement that translates the enums from the parser version to the ast version.

+/// BaseClassDecl - Represents a base class of a C++ class.
+class BaseClassDecl : public Decl {
+protected:
+ QualType Type;
+ SourceRange Range;
+ bool Virtual;
+ AccessSpecifier Access;