[cfe-commits] r39164 - in /cfe/cfe/trunk: AST/ASTContext.cpp include/clang/AST/ASTContext.h include/clang/AST/Type.h
sabre at cs.uiuc.edu
sabre at cs.uiuc.edu
Wed Jul 11 09:40:19 PDT 2007
Author: sabre
Date: Wed Jul 11 11:40:18 2007
New Revision: 39164
URL: http://llvm.org/viewvc/llvm-project?rev=39164&view=rev
Log:
add the builtin types
Modified:
cfe/cfe/trunk/AST/ASTContext.cpp
cfe/cfe/trunk/include/clang/AST/ASTContext.h
cfe/cfe/trunk/include/clang/AST/Type.h
Modified: cfe/cfe/trunk/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/ASTContext.cpp?rev=39164&r1=39163&r2=39164&view=diff
==============================================================================
--- cfe/cfe/trunk/AST/ASTContext.cpp (original)
+++ cfe/cfe/trunk/AST/ASTContext.cpp Wed Jul 11 11:40:18 2007
@@ -16,7 +16,56 @@
using namespace llvm;
using namespace clang;
+
+
+
+
+
+
+namespace {
+ /// BuiltinType - This class is used for builtin types like 'int'. Builtin
+ /// types are always canonical and have a literal name field.
+ class BuiltinType : public Type {
+ const char *Name;
+ public:
+ BuiltinType(const char *name) : Name(name) {}
+ };
+}
+
ASTContext::ASTContext(Preprocessor &pp)
: PP(pp), Target(pp.getTargetInfo()) {
+
+ // C99 6.2.5p19.
+ VoidTy = new BuiltinType("void");
+
+ // C99 6.2.5p2.
+ BoolTy = new BuiltinType("_Bool");
+ // C99 6.2.5p3.
+ CharTy = new BuiltinType("char");
+ // C99 6.2.5p4.
+ SignedCharTy = new BuiltinType("signed char");
+ ShortTy = new BuiltinType("short");
+ IntTy = new BuiltinType("int");
+ LongTy = new BuiltinType("long");
+ LongLongTy = new BuiltinType("long long");
+
+ // C99 6.2.5p6.
+ UnsignedCharTy = new BuiltinType("unsigned char");
+ UnsignedShortTy = new BuiltinType("unsigned short");
+ UnsignedIntTy = new BuiltinType("unsigned int");
+ UnsignedLongTy = new BuiltinType("unsigned long");
+ UnsignedLongLongTy = new BuiltinType("unsigned long long");
+
+ // C99 6.2.5p10.
+ FloatTy = new BuiltinType("float");
+ DoubleTy = new BuiltinType("double");
+ LongDoubleTy = new BuiltinType("long double");
+
+ // C99 6.2.5p11.
+ FloatComplexTy = new BuiltinType("float _Complex");
+ DoubleComplexTy = new BuiltinType("double _Complex");
+ LongDoubleComplexTy = new BuiltinType("long double _Complex");
+
}
+
Modified: cfe/cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/ASTContext.h?rev=39164&r1=39163&r2=39164&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/cfe/trunk/include/clang/AST/ASTContext.h Wed Jul 11 11:40:18 2007
@@ -14,6 +14,8 @@
#ifndef LLVM_CLANG_AST_ASTCONTEXT_H
#define LLVM_CLANG_AST_ASTCONTEXT_H
+#include "clang/AST/Type.h"
+
namespace llvm {
namespace clang {
class Preprocessor;
@@ -25,6 +27,17 @@
public:
Preprocessor &PP;
TargetInfo &Target;
+
+
+ // Builtin Types.
+ TypeRef VoidTy;
+ TypeRef BoolTy;
+ TypeRef CharTy;
+ TypeRef SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy;
+ TypeRef UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
+ TypeRef UnsignedLongLongTy;
+ TypeRef FloatTy, DoubleTy, LongDoubleTy;
+ TypeRef FloatComplexTy, DoubleComplexTy, LongDoubleComplexTy;
ASTContext(Preprocessor &pp);
Modified: cfe/cfe/trunk/include/clang/AST/Type.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/AST/Type.h?rev=39164&r1=39163&r2=39164&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/cfe/trunk/include/clang/AST/Type.h Wed Jul 11 11:40:18 2007
@@ -42,7 +42,7 @@
CVRFlags = Const|Volatile|Restrict
};
- TypeRef(Type *Ptr, unsigned Quals) {
+ TypeRef(Type *Ptr = 0, unsigned Quals = 0) {
assert((Quals & ~CVRFlags) == 0 && "Invalid type qualifiers!");
ThePtr = reinterpret_cast<uintptr_t>(Ptr);
assert((ThePtr & CVRFlags) == 0 && "Type pointer not 8-byte aligned?");
More information about the cfe-commits
mailing list