Add the location of the tag keyword into TagDecl. From Enea
Zaffanella, with tweaks from Abramo Bagnara.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76576 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 6b1f830..b4710c2 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -182,9 +182,9 @@
 }
 
 EnumDecl *EnumDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
-                           IdentifierInfo *Id,
+                           IdentifierInfo *Id, SourceLocation TKL,
                            EnumDecl *PrevDecl) {
-  EnumDecl *Enum = new (C) EnumDecl(DC, L, Id);
+  EnumDecl *Enum = new (C) EnumDecl(DC, L, Id, TKL);
   C.getTypeDeclType(Enum, PrevDecl);
   return Enum;
 }
@@ -654,7 +654,7 @@
 
 SourceRange TagDecl::getSourceRange() const {
   SourceLocation E = RBraceLoc.isValid() ? RBraceLoc : getLocation();
-  return SourceRange(getLocation(), E);
+  return SourceRange(TagKeywordLoc, E);
 }
 
 TagDecl* TagDecl::getCanonicalDecl() {
@@ -692,8 +692,8 @@
 //===----------------------------------------------------------------------===//
 
 RecordDecl::RecordDecl(Kind DK, TagKind TK, DeclContext *DC, SourceLocation L,
-                       IdentifierInfo *Id)
-  : TagDecl(DK, TK, DC, L, Id) {
+                       IdentifierInfo *Id, SourceLocation TKL)
+  : TagDecl(DK, TK, DC, L, Id, TKL) {
   HasFlexibleArrayMember = false;
   AnonymousStructOrUnion = false;
   HasObjectMember = false;
@@ -702,9 +702,9 @@
 
 RecordDecl *RecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                SourceLocation L, IdentifierInfo *Id,
-                               RecordDecl* PrevDecl) {
+                               SourceLocation TKL, RecordDecl* PrevDecl) {
   
-  RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id);
+  RecordDecl* R = new (C) RecordDecl(Record, TK, DC, L, Id, TKL);
   C.getTypeDeclType(R, PrevDecl);
   return R;
 }
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index 57ac611..78c3510 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -24,8 +24,9 @@
 //===----------------------------------------------------------------------===//
 
 CXXRecordDecl::CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
-                             SourceLocation L, IdentifierInfo *Id) 
-  : RecordDecl(K, TK, DC, L, Id),
+                             SourceLocation L, IdentifierInfo *Id,
+                             SourceLocation TKL) 
+  : RecordDecl(K, TK, DC, L, Id, TKL),
     UserDeclaredConstructor(false), UserDeclaredCopyConstructor(false),
     UserDeclaredCopyAssignment(false), UserDeclaredDestructor(false),
     Aggregate(true), PlainOldData(true), Polymorphic(false), Abstract(false),
@@ -36,9 +37,10 @@
 
 CXXRecordDecl *CXXRecordDecl::Create(ASTContext &C, TagKind TK, DeclContext *DC,
                                      SourceLocation L, IdentifierInfo *Id,
+                                     SourceLocation TKL,
                                      CXXRecordDecl* PrevDecl,
                                      bool DelayTypeCreation) {
-  CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id);
+  CXXRecordDecl* R = new (C) CXXRecordDecl(CXXRecord, TK, DC, L, Id, TKL);
   if (!DelayTypeCreation)
     C.getTypeDeclType(R, PrevDecl);  
   return R;