[cfe-commits] r39187 - in /cfe/cfe/trunk: AST/SemaDecl.cpp Sema/SemaDecl.cpp include/clang/AST/Decl.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:40:47 PDT 2007
Author: sabre
Date: Wed Jul 11 11:40:47 2007
New Revision: 39187
URL: http://llvm.org/viewvc/llvm-project?rev=39187&view=rev
Log:
decls should all have types
Modified:
cfe/cfe/trunk/AST/SemaDecl.cpp
cfe/cfe/trunk/Sema/SemaDecl.cpp
cfe/cfe/trunk/include/clang/AST/Decl.h
Modified: cfe/cfe/trunk/AST/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/SemaDecl.cpp?rev=39187&r1=39186&r2=39187&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/AST/SemaDecl.cpp Wed Jul 11 11:40:47 2007
@@ -60,8 +60,6 @@
Action::DeclTy *
Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
DeclTy *LastInGroup) {
- TypeRef DeclaratorType = GetTypeForDeclarator(D, S);
-
IdentifierInfo *II = D.getIdentifier();
Decl *PrevDecl = 0;
@@ -75,9 +73,9 @@
if (D.getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef) {
New = ParseTypedefDecl(S, D, PrevDecl);
} else if (D.isFunctionDeclarator())
- New = new FunctionDecl(II, PrevDecl);
+ New = new FunctionDecl(II, GetTypeForDeclarator(D, S), PrevDecl);
else
- New = new VarDecl(II, PrevDecl);
+ New = new VarDecl(II, GetTypeForDeclarator(D, S), PrevDecl);
if (!New) return 0;
@@ -111,6 +109,7 @@
Decl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, Decl *PrevDecl) {
assert(D.getIdentifier() && "Wrong callback for declspec withotu declarator");
- return new TypedefDecl(D.getIdentifier(), PrevDecl);
+ TypeRef T = GetTypeForDeclarator(D, S);
+ return new TypedefDecl(D.getIdentifier(), T, PrevDecl);
}
Modified: cfe/cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/SemaDecl.cpp?rev=39187&r1=39186&r2=39187&view=diff
==============================================================================
--- cfe/cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/cfe/trunk/Sema/SemaDecl.cpp Wed Jul 11 11:40:47 2007
@@ -60,8 +60,6 @@
Action::DeclTy *
Sema::ParseDeclarator(Scope *S, Declarator &D, ExprTy *Init,
DeclTy *LastInGroup) {
- TypeRef DeclaratorType = GetTypeForDeclarator(D, S);
-
IdentifierInfo *II = D.getIdentifier();
Decl *PrevDecl = 0;
@@ -75,9 +73,9 @@
if (D.getDeclSpec().StorageClassSpec == DeclSpec::SCS_typedef) {
New = ParseTypedefDecl(S, D, PrevDecl);
} else if (D.isFunctionDeclarator())
- New = new FunctionDecl(II, PrevDecl);
+ New = new FunctionDecl(II, GetTypeForDeclarator(D, S), PrevDecl);
else
- New = new VarDecl(II, PrevDecl);
+ New = new VarDecl(II, GetTypeForDeclarator(D, S), PrevDecl);
if (!New) return 0;
@@ -111,6 +109,7 @@
Decl *Sema::ParseTypedefDecl(Scope *S, Declarator &D, Decl *PrevDecl) {
assert(D.getIdentifier() && "Wrong callback for declspec withotu declarator");
- return new TypedefDecl(D.getIdentifier(), PrevDecl);
+ TypeRef T = GetTypeForDeclarator(D, S);
+ return new TypedefDecl(D.getIdentifier(), T, PrevDecl);
}
Modified: cfe/cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Decl.h?rev=39187&r1=39186&r2=39187&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Decl.h Wed Jul 11 11:40:47 2007
@@ -15,6 +15,7 @@
#define LLVM_CLANG_AST_DECL_H
#include "clang/Basic/SourceLocation.h"
+#include "clang/AST/Type.h"
namespace llvm {
namespace clang {
@@ -31,28 +32,29 @@
Typedef, Function, Variable
};
private:
+ /// DeclKind - This indicates which class this is.
+ Kind DeclKind;
+
/// Identifier - The identifier for this declaration (e.g. the name for the
/// variable, the tag for a struct).
IdentifierInfo *Identifier;
/// Type.
-
- /// DeclKind - This indicates which class this is.
- Kind DeclKind;
+ TypeRef DeclType;
/// Scope stack info when parsing, otherwise decl list when scope is popped.
///
Decl *Next;
public:
- Decl(IdentifierInfo *Id, Kind DK, Decl *next)
- : Identifier(Id), DeclKind(DK), Next(next) {}
+ Decl(Kind DK, IdentifierInfo *Id, TypeRef T, Decl *next)
+ : DeclKind(DK), Identifier(Id), DeclType(T), Next(next) {}
virtual ~Decl();
const IdentifierInfo *getIdentifier() const { return Identifier; }
+ TypeRef getType() const { return DeclType; }
Kind getKind() const { return DeclKind; }
-
Decl *getNext() const { return Next; }
// Implement isa/cast/dyncast/etc.
@@ -63,8 +65,8 @@
/// Objective-C classes.
class TypeDecl : public Decl {
public:
- TypeDecl(IdentifierInfo *Id, Kind DK, Decl *Next)
- : Decl(Id, DK, Next) {}
+ TypeDecl(Kind DK, IdentifierInfo *Id, TypeRef T, Decl *Next)
+ : Decl(DK, Id, T, Next) {}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == Typedef; }
@@ -74,8 +76,8 @@
class TypedefDecl : public TypeDecl {
public:
// FIXME: Remove Declarator argument.
- TypedefDecl(IdentifierInfo *Id, Decl *Next)
- : TypeDecl(Id, Typedef, Next) {}
+ TypedefDecl(IdentifierInfo *Id, TypeRef T, Decl *Next)
+ : TypeDecl(Typedef, Id, T, Next) {}
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return D->getKind() == Typedef; }
@@ -88,8 +90,8 @@
// Args etc.
Stmt *Body; // Null if a prototype.
public:
- FunctionDecl(IdentifierInfo *Id, Decl *Next)
- : Decl(Id, Function, Next), Body(0) {}
+ FunctionDecl(IdentifierInfo *Id, TypeRef T, Decl *Next)
+ : Decl(Function, Id, T, Next), Body(0) {}
Stmt *getBody() const { return Body; }
void setBody(Stmt *B) { Body = B; }
@@ -105,8 +107,8 @@
class VarDecl : public Decl {
// Initializer.
public:
- VarDecl(IdentifierInfo *Id, Decl *Next)
- : Decl(Id, Variable, Next) {}
+ VarDecl(IdentifierInfo *Id, TypeRef T, Decl *Next)
+ : Decl(Variable, Id, T, Next) {}
// Implement isa/cast/dyncast/etc.
More information about the cfe-commits
mailing list