summaryrefslogtreecommitdiff
path: root/include/clang/AST
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-06-06 08:21:31 +0000
committerEd Schouten <ed@FreeBSD.org>2009-06-06 08:21:31 +0000
commit37f6c480c696a4a72c1701ee54624cc807aa80ba (patch)
tree06d57bb7679a2140aef96db7105a0bd5f16a4358 /include/clang/AST
parent2659aeb5e51fe27d24bbffad0d1851b39fed5e43 (diff)
Diffstat (limited to 'include/clang/AST')
-rw-r--r--include/clang/AST/ASTContext.h7
-rw-r--r--include/clang/AST/Builtins.def32
-rw-r--r--include/clang/AST/Decl.h16
-rw-r--r--include/clang/AST/DeclObjC.h1
-rw-r--r--include/clang/AST/DeclTemplate.h67
-rw-r--r--include/clang/AST/ExprCXX.h9
6 files changed, 100 insertions, 32 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index e99e9f2b18f3c..cad5487ea374f 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -539,11 +539,16 @@ public:
void CollectObjCIvars(const ObjCInterfaceDecl *OI,
llvm::SmallVectorImpl<FieldDecl*> &Fields);
-
+
+ void ShallowCollectObjCIvars(const ObjCInterfaceDecl *OI,
+ llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars,
+ bool CollectSynthesized = true);
void CollectSynthesizedIvars(const ObjCInterfaceDecl *OI,
llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
void CollectProtocolSynthesizedIvars(const ObjCProtocolDecl *PD,
llvm::SmallVectorImpl<ObjCIvarDecl*> &Ivars);
+ unsigned CountSynthesizedIvars(const ObjCInterfaceDecl *OI);
+ unsigned CountProtocolSynthesizedIvars(const ObjCProtocolDecl *PD);
//===--------------------------------------------------------------------===//
// Type Operators
diff --git a/include/clang/AST/Builtins.def b/include/clang/AST/Builtins.def
index 11f3264faa2d2..c2f4061c5d789 100644
--- a/include/clang/AST/Builtins.def
+++ b/include/clang/AST/Builtins.def
@@ -332,25 +332,31 @@ BUILTIN(__sync_fetch_and_max, "ii*i", "n")
BUILTIN(__sync_fetch_and_umin, "UiUi*Ui", "n")
BUILTIN(__sync_fetch_and_umax, "UiUi*Ui", "n")
-// Builtin library functions
-LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")
+// C99 library functions
+// C99 stdlib.h
LIBBUILTIN(calloc, "v*zz", "f", "stdlib.h")
LIBBUILTIN(malloc, "v*z", "f", "stdlib.h")
LIBBUILTIN(realloc, "v*v*z", "f", "stdlib.h")
+// C99 string.h
LIBBUILTIN(memcpy, "v*v*vC*z", "f", "string.h")
LIBBUILTIN(memmove, "v*v*vC*z", "f", "string.h")
-LIBBUILTIN(memset, "v*v*iz", "f", "string.h")
+LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h")
LIBBUILTIN(strcat, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h")
+LIBBUILTIN(strxfrm, "zc*cC*z", "f", "string.h")
+LIBBUILTIN(memchr, "v*vC*iz", "f", "string.h")
LIBBUILTIN(strchr, "c*cC*i", "f", "string.h")
-LIBBUILTIN(strcpy, "c*c*cC*", "f", "string.h")
LIBBUILTIN(strcspn, "zcC*cC*", "f", "string.h")
-LIBBUILTIN(strlen, "zcC*", "f", "string.h")
-LIBBUILTIN(strncat, "c*c*cC*z", "f", "string.h")
-LIBBUILTIN(strncpy, "c*c*cC*z", "f", "string.h")
LIBBUILTIN(strpbrk, "c*cC*cC*", "f", "string.h")
LIBBUILTIN(strrchr, "c*cC*i", "f", "string.h")
LIBBUILTIN(strspn, "zcC*cC*", "f", "string.h")
LIBBUILTIN(strstr, "c*cC*cC*", "f", "string.h")
+LIBBUILTIN(strtok, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(memset, "v*v*iz", "f", "string.h")
+LIBBUILTIN(strerror, "c*i", "f", "string.h")
+LIBBUILTIN(strlen, "zcC*", "f", "string.h")
+// C99 stdio.h
LIBBUILTIN(printf, "icC*.", "fp:0:", "stdio.h")
LIBBUILTIN(fprintf, "iP*cC*.", "fp:1:", "stdio.h")
LIBBUILTIN(snprintf, "ic*zcC*.", "fp:2:", "stdio.h")
@@ -360,6 +366,18 @@ LIBBUILTIN(vfprintf, "i.", "fP:1:", "stdio.h")
LIBBUILTIN(vsnprintf, "ic*zcC*a", "fP:2:", "stdio.h")
LIBBUILTIN(vsprintf, "ic*cC*a", "fP:1:", "stdio.h")
+// Non-C library functions
+// FIXME: Non-C-standard stuff shouldn't be builtins in non-GNU mode!
+LIBBUILTIN(alloca, "v*z", "f", "stdlib.h")
+// POSIX string.h
+LIBBUILTIN(stpcpy, "c*c*cC*", "f", "string.h")
+LIBBUILTIN(stpncpy, "c*c*cC*z", "f", "string.h")
+LIBBUILTIN(strdup, "c*cC*", "f", "string.h")
+LIBBUILTIN(strndup, "c*cC*z", "f", "string.h")
+// POSIX strings.h
+LIBBUILTIN(index, "c*cC*i", "f", "strings.h")
+LIBBUILTIN(rindex, "c*cC*i", "f", "strings.h")
+
// FIXME: This type isn't very correct, it should be
// id objc_msgSend(id, SEL)
// but we need new type letters for that.
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index e134aed73d770..7440e7b5f1508 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -515,10 +515,22 @@ public:
objcDeclQualifier = QTVal;
}
- const Expr *getDefaultArg() const { return DefaultArg; }
- Expr *getDefaultArg() { return DefaultArg; }
+ const Expr *getDefaultArg() const {
+ assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
+ return DefaultArg;
+ }
+ Expr *getDefaultArg() {
+ assert(!hasUnparsedDefaultArg() && "Default argument is not yet parsed!");
+ return DefaultArg;
+ }
void setDefaultArg(Expr *defarg) { DefaultArg = defarg; }
+ /// hasDefaultArg - Determines whether this parameter has a default argument,
+ /// either parsed or not.
+ bool hasDefaultArg() const {
+ return DefaultArg != 0;
+ }
+
/// hasUnparsedDefaultArg - Determines whether this parameter has a
/// default argument that has not yet been parsed. This will occur
/// during the processing of a C++ class whose member functions have
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 6e89a7ae7bc9f..3943ddc19638c 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -330,6 +330,7 @@ public:
// Get the local instance/class method declared in this interface.
ObjCMethodDecl *getInstanceMethod(ASTContext &Context, Selector Sel) const;
ObjCMethodDecl *getClassMethod(ASTContext &Context, Selector Sel) const;
+ ObjCIvarDecl *getIvarDecl(ASTContext &Context, IdentifierInfo *Id) const;
ObjCMethodDecl *
getMethod(ASTContext &Context, Selector Sel, bool isInstance) const {
diff --git a/include/clang/AST/DeclTemplate.h b/include/clang/AST/DeclTemplate.h
index 226af3411d551..d1899006cc82f 100644
--- a/include/clang/AST/DeclTemplate.h
+++ b/include/clang/AST/DeclTemplate.h
@@ -203,6 +203,9 @@ public:
/// Get the position of the template parameter within its parameter list.
unsigned getPosition() const { return Position; }
+
+ /// Get the index of the template parameter within its parameter list.
+ unsigned getIndex() const { return Position; }
};
/// TemplateTypeParmDecl - Declaration of a template type parameter,
@@ -299,7 +302,8 @@ public:
using TemplateParmPosition::getDepth;
using TemplateParmPosition::getPosition;
-
+ using TemplateParmPosition::getIndex;
+
/// \brief Determine whether this template parameter has a default
/// argument.
bool hasDefaultArgument() const { return DefaultArgument; }
@@ -350,7 +354,8 @@ public:
using TemplateParmPosition::getDepth;
using TemplateParmPosition::getPosition;
-
+ using TemplateParmPosition::getIndex;
+
/// \brief Determine whether this template parameter has a default
/// argument.
bool hasDefaultArgument() const { return DefaultArgument; }
@@ -390,20 +395,21 @@ class TemplateArgument {
public:
/// \brief The type of template argument we're storing.
enum ArgKind {
+ Null = 0,
/// The template argument is a type. It's value is stored in the
/// TypeOrValue field.
- Type = 0,
+ Type = 1,
/// The template argument is a declaration
- Declaration = 1,
+ Declaration = 2,
/// The template argument is an integral value stored in an llvm::APSInt.
- Integral = 2,
+ Integral = 3,
/// The template argument is a value- or type-dependent expression
/// stored in an Expr*.
- Expression = 3
+ Expression = 4
} Kind;
/// \brief Construct an empty, invalid template argument.
- TemplateArgument() : TypeOrValue(0), StartLoc(), Kind(Type) { }
+ TemplateArgument() : TypeOrValue(0), StartLoc(), Kind(Null) { }
/// \brief Construct a template type argument.
TemplateArgument(SourceLocation Loc, QualType T) : Kind(Type) {
@@ -484,6 +490,9 @@ public:
/// \brief Return the kind of stored template argument.
ArgKind getKind() const { return Kind; }
+ /// \brief Determine whether this template argument has no value.
+ bool isNull() const { return Kind == Null; }
+
/// \brief Retrieve the template argument as a type.
QualType getAsType() const {
if (Kind != Type)
@@ -519,6 +528,12 @@ public:
return QualType::getFromOpaquePtr(Integer.Type);
}
+ void setIntegralType(QualType T) {
+ assert(Kind == Integral &&
+ "Cannot set the integral type of a non-integral template argument");
+ Integer.Type = T.getAsOpaquePtr();
+ };
+
/// \brief Retrieve the template argument as an expression.
Expr *getAsExpr() const {
if (Kind != Expression)
@@ -534,6 +549,9 @@ public:
void Profile(llvm::FoldingSetNodeID &ID) const {
ID.AddInteger(Kind);
switch (Kind) {
+ case Null:
+ break;
+
case Type:
getAsType().Profile(ID);
break;
@@ -555,6 +573,22 @@ public:
}
};
+/// \brief A helper class for making template argument lists.
+class TemplateArgumentListBuilder {
+ llvm::SmallVector<TemplateArgument, 16> Args;
+
+ ASTContext &Context;
+public:
+ TemplateArgumentListBuilder(ASTContext &Context) : Context(Context) { }
+
+ // FIXME: Should use the index array size.
+ size_t size() const { return Args.size(); }
+ size_t flatSize() const { return Args.size(); }
+
+ void push_back(const TemplateArgument& Arg);
+ TemplateArgument *getFlatArgumentList() { return Args.data(); }
+};
+
/// \brief A template argument list.
///
/// FIXME: In the future, this class will be extended to support
@@ -571,12 +605,10 @@ class TemplateArgumentList {
/// argument list.
unsigned NumArguments;
-
public:
TemplateArgumentList(ASTContext &Context,
- TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs,
- bool CopyArgs);
+ TemplateArgumentListBuilder &Builder,
+ bool CopyArgs, bool FlattenArgs);
~TemplateArgumentList();
@@ -660,14 +692,13 @@ protected:
ClassTemplateSpecializationDecl(ASTContext &Context, Kind DK,
DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs);
+ TemplateArgumentListBuilder &Builder);
public:
static ClassTemplateSpecializationDecl *
Create(ASTContext &Context, DeclContext *DC, SourceLocation L,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs, unsigned NumTemplateArgs,
+ TemplateArgumentListBuilder &Builder,
ClassTemplateSpecializationDecl *PrevDecl);
/// \brief Retrieve the template that this specialization specializes.
@@ -730,11 +761,9 @@ class ClassTemplatePartialSpecializationDecl
DeclContext *DC, SourceLocation L,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs,
- unsigned NumTemplateArgs)
+ TemplateArgumentListBuilder &Builder)
: ClassTemplateSpecializationDecl(Context, ClassTemplatePartialSpecialization,
- DC, L, SpecializedTemplate, TemplateArgs,
- NumTemplateArgs),
+ DC, L, SpecializedTemplate, Builder),
TemplateParams(Params) { }
public:
@@ -742,7 +771,7 @@ public:
Create(ASTContext &Context, DeclContext *DC, SourceLocation L,
TemplateParameterList *Params,
ClassTemplateDecl *SpecializedTemplate,
- TemplateArgument *TemplateArgs, unsigned NumTemplateArgs,
+ TemplateArgumentListBuilder &Builder,
ClassTemplatePartialSpecializationDecl *PrevDecl);
/// Get the list of template parameters
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 53386231a03fa..e44ccca0bd74e 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -1023,14 +1023,17 @@ class CXXExprWithTemporaries : public Expr {
CXXTemporary **Temps;
unsigned NumTemps;
- CXXExprWithTemporaries(Expr *subexpr, CXXTemporary **temps,
- unsigned numtemps);
+ bool DestroyTemps;
+
+ CXXExprWithTemporaries(Expr *SubExpr, CXXTemporary **Temps,
+ unsigned NumTemps, bool DestroyTemps);
~CXXExprWithTemporaries();
public:
static CXXExprWithTemporaries *Create(ASTContext &C, Expr *SubExpr,
CXXTemporary **Temps,
- unsigned NumTemps);
+ unsigned NumTemps,
+ bool DestroyTems);
void Destroy(ASTContext &C);
unsigned getNumTemporaries() const { return NumTemps; }