//===-- DeclCXX.h - Classes for representing C++ declarations -*- C++ -*-=====//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file defines the C++ Decl subclasses.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_DECLCXX_H
#define LLVM_CLANG_AST_DECLCXX_H
#include "clang/AST/Decl.h"
#include "llvm/ADT/SmallVector.h"
namespace clang {
class ClassTemplateDecl;
class CXXRecordDecl;
class CXXConstructorDecl;
class CXXDestructorDecl;
class CXXConversionDecl;
class CXXMethodDecl;
class ClassTemplateSpecializationDecl;
/// \brief Represents any kind of function declaration, whether it is a
/// concrete function or a function template.
class AnyFunctionDecl {
NamedDecl *Function;
AnyFunctionDecl(NamedDecl *ND) : Function(ND) { }
public:
AnyFunctionDecl(FunctionDecl *FD) : Function(FD) { }
AnyFunctionDecl(FunctionTemplateDecl *FTD);
/// \brief Implicily converts any function or function template into a
/// named declaration.
operator NamedDecl *() const { return Function; }
/// \brief Retrieve the underlying function or function template.
NamedDecl *get() const { return Function; }
static AnyFunctionDecl getFromNamedDecl(NamedDecl *ND) {
return AnyFunctionDecl(ND);
}
};
} // end namespace clang
namespace llvm {
/// Implement simplify_type for AnyFunctionDecl, so that we can dyn_cast from
/// AnyFunctionDecl to any function or function template declaration.
template<> struct simplify_type<const ::clang::AnyFunctionDecl> {
typedef ::clang::NamedDecl* SimpleType;
static SimpleType getSimplifiedValue(const ::clang::AnyFunctionDecl &Val) {
return Val;
}
};
template<> struct simplify_type< ::clang::AnyFunctionDecl>
: public simplify_type<const ::clang::AnyFunctionDecl> {};
// Provide PointerLikeTypeTraits for non-cvr pointers.
template<>
class PointerLikeTypeTraits< ::clang::AnyFunctionDecl> {
public:
static inline void *getAsVoidPointer(::clang::AnyFunctionDecl F) {
return F.get();
}
static inline ::clang::AnyFunctionDecl getFromVoidPointer(void *P) {
return ::clang::AnyFunctionDecl::getFromNamedDecl(
static_cast< ::clang::NamedDecl*>(P));
}
enum { NumLowBitsAvailable = 2 };
};
} // end namespace llvm
namespace clang {
/// OverloadedFunctionDecl - An instance of this class represents a
/// set of overloaded functions. All of the functions have the same
/// name and occur within the same scope.
///
/// An OverloadedFunctionDecl has no ownership over the FunctionDecl
/// nodes it contains. Rather, the FunctionDecls are owned by the
/// enclosing scope (which also owns the OverloadedFunctionDecl
/// node). OverloadedFunctionDecl is used primarily to store a set of
/// overloaded functions for name lookup.
class OverloadedFunctionDecl : public NamedDecl {
protected:
OverloadedFunctionDecl(DeclContext *DC, DeclarationName N)
: NamedDecl(OverloadedFunction, DC, SourceLocation(), N) { }
/// Functions - the set of overloaded functions contained in this
/// overload set.
llvm::SmallVector<AnyFunctionDecl, 4> Functions;
// FIXME: This should go away when we stop using
// OverloadedFunctionDecl to store conversions in CXXRecordDecl.
friend class CXXRecordDecl;
public:
typedef llvm::SmallVector<AnyFunctionDecl, 4>::iterator function_iterator;
typedef llvm::SmallVector<AnyFunctionDecl, 4>::const_iterator
function_const_iterator;
static OverloadedFunctionDecl