aboutsummaryrefslogtreecommitdiff
path: root/include/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-07-29 23:36:44 +0000
committerDouglas Gregor <dgregor@apple.com>2009-07-29 23:36:44 +0000
commit8e9e9ef5348bce1a8f0741a5684fac3de9701c28 (patch)
treeda4ef264be5202213f0470cd5c9fa42dcf654fa6 /include/clang
parent5266d2ed446e9588eb00579ddfc5a2d327a5b3ab (diff)
Make tag declarations redeclarable. This change has three purposes:
1) Allow the Index library (and any other interested client) to walk the set of declarations for a given tag (enum, union, class, whatever). At the moment, this information is not readily available. 2) Reduce our dependence on TagDecl::TypeForDecl being mapped down to a TagType (for which getDecl() will return the tag definition, if one exists). This property won't exist for class template partial specializations. 3) Make the canonical declaration of a TagDecl actually canonical, e.g., so that it does not change when the tag is defined. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77523 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang')
-rw-r--r--include/clang/AST/Decl.h27
-rw-r--r--include/clang/AST/DeclCXX.h1
-rw-r--r--include/clang/AST/DeclTemplate.h12
3 files changed, 30 insertions, 10 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index 3214b653b9..9ce589ba80 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -1178,7 +1178,8 @@ public:
class TypedefDecl;
/// TagDecl - Represents the declaration of a struct/union/class/enum.
-class TagDecl : public TypeDecl, public DeclContext {
+class TagDecl
+ : public TypeDecl, public DeclContext, public Redeclarable<TagDecl> {
public:
enum TagKind {
TK_struct,
@@ -1205,15 +1206,28 @@ private:
protected:
TagDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, SourceLocation TKL = SourceLocation())
+ IdentifierInfo *Id, TagDecl *PrevDecl,
+ SourceLocation TKL = SourceLocation())
: TypeDecl(DK, DC, L, Id), DeclContext(DK), TypedefForAnonDecl(0),
TagKeywordLoc(TKL) {
assert((DK != Enum || TK == TK_enum) &&"EnumDecl not matched with TK_enum");
TagDeclKind = TK;
IsDefinition = false;
+ setPreviousDeclaration(PrevDecl);
}
+
+ typedef Redeclarable<TagDecl> redeclarable_base;
+ virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+
public:
-
+ typedef redeclarable_base::redecl_iterator redecl_iterator;
+ redecl_iterator redecls_begin() const {
+ return redeclarable_base::redecls_begin();
+ }
+ redecl_iterator redecls_end() const {
+ return redeclarable_base::redecls_end();
+ }
+
SourceLocation getRBraceLoc() const { return RBraceLoc; }
void setRBraceLoc(SourceLocation L) { RBraceLoc = L; }
@@ -1307,8 +1321,8 @@ class EnumDecl : public TagDecl {
EnumDecl *InstantiatedFrom;
EnumDecl(DeclContext *DC, SourceLocation L,
- IdentifierInfo *Id, SourceLocation TKL)
- : TagDecl(Enum, TK_enum, DC, L, Id, TKL), InstantiatedFrom(0) {
+ IdentifierInfo *Id, EnumDecl *PrevDecl, SourceLocation TKL)
+ : TagDecl(Enum, TK_enum, DC, L, Id, PrevDecl, TKL), InstantiatedFrom(0) {
IntegerType = QualType();
}
public:
@@ -1380,7 +1394,8 @@ class RecordDecl : public TagDecl {
protected:
RecordDecl(Kind DK, TagKind TK, DeclContext *DC,
- SourceLocation L, IdentifierInfo *Id, SourceLocation TKL);
+ SourceLocation L, IdentifierInfo *Id,
+ RecordDecl *PrevDecl, SourceLocation TKL);
virtual ~RecordDecl();
public:
diff --git a/include/clang/AST/DeclCXX.h b/include/clang/AST/DeclCXX.h
index 8ad8aede60..3da7230ab0 100644
--- a/include/clang/AST/DeclCXX.h
+++ b/include/clang/AST/DeclCXX.h
@@ -376,6 +376,7 @@ class CXXRecordDecl : public RecordDecl {
protected:
CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
+ CXXRecordDecl *PrevDecl,
SourceLocation TKL = SourceLocation());
~CXXRecordDecl();
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 17c8bc877d..7cf8bfdecf 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -883,7 +883,8 @@ protected:
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK,
DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgumentListBuilder &Builder);
+ TemplateArgumentListBuilder &Builder,
+ ClassTemplateSpecializationDecl *PrevDecl);
public:
static ClassTemplateSpecializationDecl *
@@ -954,9 +955,12 @@ class ClassTemplatePartialSpecializationDecl
DeclContext *DC, SourceLocation L,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgumentListBuilder &Builder)
- : ClassTemplateSpecializationDecl(Context, ClassTemplatePartialSpecialization,
- DC, L, SpecializedTemplate, Builder),
+ TemplateArgumentListBuilder &Builder,
+ ClassTemplatePartialSpecializationDecl *PrevDecl)
+ : ClassTemplateSpecializationDecl(Context,
+ ClassTemplatePartialSpecialization,
+ DC, L, SpecializedTemplate, Builder,
+ PrevDecl),
TemplateParams(Params) { }
public: