aboutsummaryrefslogtreecommitdiff
path: root/lib/AST
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2008-11-07 20:08:42 +0000
committerDouglas Gregor <dgregor@apple.com>2008-11-07 20:08:42 +0000
commit2f1bc5285ccd40f411af5f5993f013e27e74ab78 (patch)
tree13b6547acb399a89753f742a0595aea613cecc36 /lib/AST
parent9057a81efaf15c543aab1c5c8488e8a9ed2c0ff4 (diff)
Parsing, ASTs, and semantic analysis for the declaration of conversion
functions in C++, e.g., struct X { operator bool() const; }; Note that these conversions don't actually do anything, since we don't yet have the ability to use them for implicit or explicit conversions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST')
-rw-r--r--lib/AST/DeclBase.cpp1
-rw-r--r--lib/AST/DeclCXX.cpp18
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index de7a1d3ca4..7e51ef5010 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -239,6 +239,7 @@ void Decl::addDeclKind(Kind k) {
case CXXMethod:
case CXXConstructor:
case CXXDestructor:
+ case CXXConversion:
case CXXClassVar:
break;
}
diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp
index b0df75b404..b2878b667a 100644
--- a/lib/AST/DeclCXX.cpp
+++ b/lib/AST/DeclCXX.cpp
@@ -48,6 +48,11 @@ void CXXRecordDecl::Destroy(ASTContext &C) {
if (isDefinition())
Destructor->Destroy(C);
+ for (OverloadedFunctionDecl::function_iterator func
+ = Conversions.function_begin();
+ func != Conversions.function_end(); ++func)
+ (*func)->Destroy(C);
+
RecordDecl::Destroy(C);
}
@@ -101,6 +106,11 @@ CXXRecordDecl::addConstructor(ASTContext &Context,
Constructors.addOverload(ConDecl);
}
+void CXXRecordDecl::addConversionFunction(ASTContext &Context,
+ CXXConversionDecl *ConvDecl) {
+ Conversions.addOverload(ConvDecl);
+}
+
CXXMethodDecl *
CXXMethodDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, IdentifierInfo *Id,
@@ -232,6 +242,14 @@ CXXDestructorDecl::Create(ASTContext &C, CXXRecordDecl *RD,
isImplicitlyDeclared);
}
+CXXConversionDecl *
+CXXConversionDecl::Create(ASTContext &C, CXXRecordDecl *RD,
+ SourceLocation L, IdentifierInfo *Id,
+ QualType T, bool isInline, bool isExplicit) {
+ void *Mem = C.getAllocator().Allocate<CXXConversionDecl>();
+ return new (Mem) CXXConversionDecl(RD, L, Id, T, isInline, isExplicit);
+}
+
CXXClassVarDecl *CXXClassVarDecl::Create(ASTContext &C, CXXRecordDecl *RD,
SourceLocation L, IdentifierInfo *Id,
QualType T, ScopedDecl *PrevDecl) {