//===--- DeclObjC.h - Classes for representing 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 DeclObjC interface and subclasses.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CLANG_AST_DECLOBJC_H
#define LLVM_CLANG_AST_DECLOBJC_H
#include "clang/AST/Decl.h"
#include "clang/Basic/IdentifierTable.h"
#include "llvm/ADT/DenseMap.h"
namespace clang {
class Expr;
class Stmt;
class FunctionDecl;
class AttributeList;
class RecordDecl;
class ObjCIvarDecl;
class ObjCMethodDecl;
class ObjCProtocolDecl;
class ObjCCategoryDecl;
class ObjCPropertyDecl;
class ObjCPropertyImplDecl;
/// ObjCList - This is a simple template class used to hold various lists of
/// decls etc, which is heavily used by the ObjC front-end. This only use case
/// this supports is setting the list all at once and then reading elements out
/// of it.
template <typename T>
class ObjCList {
/// List is a new[]'d array of pointers to objects that are not owned by this
/// list.
T **List;
unsigned NumElts;
void operator=(const ObjCList &); // DO NOT IMPLEMENT
ObjCList(const ObjCList&); // DO NOT IMPLEMENT
public:
ObjCList() : List(0), NumElts(0) {}
~ObjCList() {
delete[] List;
}
void set(T* const* InList, unsigned Elts) {
assert(List == 0 && "Elements already set!");
List = new T*[Elts];
NumElts = Elts;
memcpy(List, InList, sizeof(T*)*Elts);
}
typedef T* const * iterator;
iterator begin() const { return List; }
iterator end() const { return List+NumElts; }
unsigned size() const { return NumElts; }
bool empty() const { return NumElts == 0; }
T* operator[](unsigned idx) const {
assert(idx < NumElts && "Invalid access");
return List[idx];
}
};
/// ObjCMethodDecl - Represents an instance or class method declaration.
/// ObjC methods can be declared within 4 contexts: class interfaces,
/// categories, protocols, and class implementations. While C++ member
/// functions leverage C syntax, Objective-C method syntax is modeled after
/// Smalltalk (using colons to specify argument types/expressions).
/// Here are some brief examples:
///
/// Setter/getter instance methods:
/// - (void)setMenu:(NSMenu *)menu;
/// - (NSMenu *)menu;
///
/// Instance method that takes 2 NSView arguments:
/// - (void)replaceSubview:(NSView *)oldView with:(NSView *)newView;
///
/// Getter class method:
/// + (NSMenu *)defaultMenu;
///
/// A selector represents a unique name for a method. The selector names for
/// the above methods are setMenu:, menu, replaceSubview:with:, and defaultMenu.
///
class ObjCMethodDecl : public ScopedDecl, public DeclContext {
public:
enum ImplementationControl { None, Required, Optional };
private:
/// Bitfields must be first fields in this class so they pack with those
/// declared in class Decl.
/// instance (true) or class (false) method.
bool IsInstance : 1;
bool IsVariadic : 1;
// Synthesized declaration method for a property setter/getter
bool IsSynthesized : 1;
// NOTE: VC++ treats enums as signed, avoid using ImplementationControl enum
/// @required/@optional
unsigned