//===-- DeclXML.def - Metadata about Decl XML nodes ------------*- 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 XML statement database structure as written in
//  <TranslationUnit> sub-nodes of the XML document.
//  The semantics of the attributes and enums are mostly self-documenting
//  by looking at the appropriate internally used functions and values.
//  The following macros are used:
//
//  NODE_XML( CLASS, NAME ) - A node of name NAME denotes a concrete
//  statement of class CLASS where CLASS is a class name used internally by clang.
//  After a NODE_XML the definition of all (optional) attributes of that statement
//  node and possible sub-nodes follows.
//
//  END_NODE_XML - Closes the attribute definition of the current node.
//
//  ID_ATTRIBUTE_XML - Some statement nodes have an "id" attribute containing a
//  string, which value uniquely identify that statement. Other nodes may refer
//  by reference attributes to this value (currently used only for Label).
//
//  TYPE_ATTRIBUTE_XML( FN ) - Type nodes refer to the result type id of an
//  expression by a "type" attribute. FN is internally used by clang.
//
//  ATTRIBUTE_XML( FN, NAME ) - An attribute named NAME. FN is internally
//  used by clang. A boolean attribute have the values "0" or "1".
//
//  ATTRIBUTE_SPECIAL_XML( FN, NAME ) - An attribute named NAME which deserves
//  a special handling. See the appropriate documentations.
//
//  ATTRIBUTE_FILE_LOCATION_XML - A bunch of attributes denoting the location of
//  a statement in the source file(s).
//
//  ATTRIBUTE_OPT_XML( FN, NAME ) - An optional attribute named NAME.
//  Optional attributes are omitted for boolean types, if the value is false,
//  for integral types, if the value is null and for strings,
//  if the value is the empty string. FN is internally used by clang.
//
//  ATTRIBUTE_ENUM[_OPT]_XML( FN, NAME ) - An attribute named NAME. The value
//  is an enumeration defined with ENUM_XML macros immediately following after
//  that macro. An optional attribute is ommited, if the particular enum is the
//  empty string. FN is internally used by clang.
//
//  ENUM_XML( VALUE, NAME ) - An enumeration element named NAME. VALUE is
//  internally used by clang.
//
//  END_ENUM_XML - Closes the enumeration definition of the current attribute.
//
//  SUB_NODE_XML( CLASS ) - A mandatory sub-node of class CLASS or its sub-classes.
//
//  SUB_NODE_OPT_XML( CLASS ) - An optional sub-node of class CLASS or its sub-classes.
//
//  SUB_NODE_SEQUENCE_XML( CLASS ) - Zero or more sub-nodes of class CLASS or
//  its sub-classes.
//
//===----------------------------------------------------------------------===//

#ifndef ATTRIBUTE_FILE_LOCATION_XML
#  define ATTRIBUTE_FILE_LOCATION_XML             \
     ATTRIBUTE_XML(getFilename(), "file")         \
     ATTRIBUTE_XML(getLine(), "line")             \
     ATTRIBUTE_XML(getColumn(), "col")            \
     ATTRIBUTE_OPT_XML(getFilename(), "endfile")  \
     ATTRIBUTE_OPT_XML(getLine(), "endline")      \
     ATTRIBUTE_OPT_XML(getColumn(), "endcol")
#endif

#ifndef TYPE_ATTRIBUTE_XML
#  define TYPE_ATTRIBUTE_XML( FN )    ATTRIBUTE_XML(FN, "type")
#endif

#ifndef CONTEXT_ATTRIBUTE_XML
#  define CONTEXT_ATTRIBUTE_XML( FN ) ATTRIBUTE_XML(FN, "context")
#endif

//NODE_XML(TranslationUnitDecl, "TranslationUnit")
//  SUB_NODE_SEQUENCE_XML(Decl)
//END_NODE_XML

NODE_XML(Decl, "FIXME_Decl")
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclKindName(), "unhandled_decl_name")
END_NODE_XML

NODE_XML(FunctionDecl, "Function")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
	  ENUM_XML(FunctionDecl::None, "")
	  ENUM_XML(FunctionDecl::Extern, "extern")
	  ENUM_XML(FunctionDecl::Static, "static")
	  ENUM_XML(FunctionDecl::PrivateExtern, "__private_extern__")
  END_ENUM_XML
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  //ATTRIBUTE_OPT_XML(isVariadic(), "variadic")       // in the type reference
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  SUB_NODE_FN_BODY_XML
END_NODE_XML

NODE_XML(CXXMethodDecl, "CXXMethod")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  ATTRIBUTE_OPT_XML(isStatic(), "static")
  ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
  ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access")
	  ENUM_XML(AS_none,      "")
	  ENUM_XML(AS_public,    "public")
	  ENUM_XML(AS_protected, "protected")
	  ENUM_XML(AS_private,   "private")
  END_ENUM_XML
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  SUB_NODE_FN_BODY_XML
END_NODE_XML

NODE_XML(CXXConstructorDecl, "CXXConstructor")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_OPT_XML(isExplicit(), "is_explicit")
  ATTRIBUTE_OPT_XML(isDefaultConstructor(), "is_default_ctor")
  ATTRIBUTE_OPT_XML(isCopyConstructor(), "is_copy_ctor")
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  ATTRIBUTE_OPT_XML(isStatic(), "static")
  ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
  ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access")
	  ENUM_XML(AS_none,      "")
	  ENUM_XML(AS_public,    "public")
	  ENUM_XML(AS_protected, "protected")
	  ENUM_XML(AS_private,   "private")
  END_ENUM_XML
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  SUB_NODE_FN_BODY_XML
END_NODE_XML

NODE_XML(CXXDestructorDecl, "CXXDestructor")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  ATTRIBUTE_OPT_XML(isStatic(), "static")
  ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
  ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access")
	  ENUM_XML(AS_none,      "")
	  ENUM_XML(AS_public,    "public")
	  ENUM_XML(AS_protected, "protected")
	  ENUM_XML(AS_private,   "private")
  END_ENUM_XML
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  SUB_NODE_FN_BODY_XML
END_NODE_XML

NODE_XML(CXXConversionDecl, "CXXConversion")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType()->getAs<FunctionType>()->getResultType())
  ATTRIBUTE_XML(getType()->getAs<FunctionType>(), "function_type")
  ATTRIBUTE_OPT_XML(isExplicit(), "is_explicit")
  ATTRIBUTE_OPT_XML(isInlineSpecified(), "inline")
  ATTRIBUTE_OPT_XML(isStatic(), "static")
  ATTRIBUTE_OPT_XML(isVirtual(), "virtual")
  ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access")
	  ENUM_XML(AS_none,      "")
	  ENUM_XML(AS_public,    "public")
	  ENUM_XML(AS_protected, "protected")
	  ENUM_XML(AS_private,   "private")
  END_ENUM_XML
  ATTRIBUTE_XML(getNumParams(), "num_args")
  SUB_NODE_SEQUENCE_XML(ParmVarDecl)
  SUB_NODE_FN_BODY_XML
END_NODE_XML

NODE_XML(NamespaceDecl, "Namespace")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  SUB_NODE_SEQUENCE_XML(DeclContext)
END_NODE_XML

NODE_XML(UsingDirectiveDecl, "UsingDirective")
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_XML(getNominatedNamespace(), "ref")
END_NODE_XML

NODE_XML(NamespaceAliasDecl, "NamespaceAlias")
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_XML(getNamespace(), "ref")
END_NODE_XML

NODE_XML(RecordDecl, "Record")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
  ATTRIBUTE_XML(getTypeForDecl(), "type")             // refers to the type this decl creates
  SUB_NODE_SEQUENCE_XML(FieldDecl)
END_NODE_XML

NODE_XML(CXXRecordDecl, "CXXRecord")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
  ATTRIBUTE_XML(getTypeForDecl(), "type")             // refers to the type this decl creates
  SUB_NODE_SEQUENCE_XML(FieldDecl)
END_NODE_XML

NODE_XML(EnumDecl, "Enum")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  ATTRIBUTE_OPT_XML(isDefinition() == false, "forward")
  ATTRIBUTE_SPECIAL_XML(getIntegerType(), "type")     // is NULL in pure declarations thus deserves special handling
  SUB_NODE_SEQUENCE_XML(EnumConstantDecl)             // only present in definition
END_NODE_XML

NODE_XML(EnumConstantDecl, "EnumConstant")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_XML(getInitVal().toString(10, true), "value")     // integer
  SUB_NODE_OPT_XML(Expr)                                      // init expr of this constant
END_NODE_XML

NODE_XML(FieldDecl, "Field")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_OPT_XML(isMutable(), "mutable")
  ATTRIBUTE_ENUM_OPT_XML(getAccess(), "access")
	  ENUM_XML(AS_none,      "")
	  ENUM_XML(AS_public,    "public")
	  ENUM_XML(AS_protected, "protected")
	  ENUM_XML(AS_private,   "private")
  END_ENUM_XML
  ATTRIBUTE_OPT_XML(isBitField(), "bitfield")
  SUB_NODE_OPT_XML(Expr)                                      // init expr of a bit field
END_NODE_XML

NODE_XML(TypedefDecl, "Typedef")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getUnderlyingType())
END_NODE_XML

NODE_XML(VarDecl, "Var")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  ATTRIBUTE_ENUM_OPT_XML(getStorageClass(), "storage_class")
	  ENUM_XML(VarDecl::None, "")
	  ENUM_XML(VarDecl::Auto, "auto")
	  ENUM_XML(VarDecl::Register, "register")
	  ENUM_XML(VarDecl::Extern, "extern")
	  ENUM_XML(VarDecl::Static, "static")
	  ENUM_XML(VarDecl::PrivateExtern, "__private_extern__")
  END_ENUM_XML
  SUB_NODE_OPT_XML(Expr)                                      // init expr
END_NODE_XML

NODE_XML(ParmVarDecl, "ParmVar")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
  TYPE_ATTRIBUTE_XML(getType())
  SUB_NODE_OPT_XML(Expr)                                      // default argument expression
END_NODE_XML

NODE_XML(LinkageSpecDecl, "LinkageSpec")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_ENUM_OPT_XML(getLanguage(), "lang")
	  ENUM_XML(LinkageSpecDecl::lang_c, "C")
	  ENUM_XML(LinkageSpecDecl::lang_cxx, "CXX")
  END_ENUM_XML
END_NODE_XML

NODE_XML(TemplateDecl, "Template")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
END_NODE_XML

NODE_XML(TemplateTypeParmDecl, "TemplateTypeParm")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getNameAsString(), "name")
END_NODE_XML

NODE_XML(UsingShadowDecl, "UsingShadow")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getTargetDecl(), "target_decl")
  ATTRIBUTE_XML(getUsingDecl(), "using_decl")
END_NODE_XML

NODE_XML(UsingDecl, "Using")
  ID_ATTRIBUTE_XML
  ATTRIBUTE_FILE_LOCATION_XML
  ATTRIBUTE_XML(getDeclContext(), "context")
  ATTRIBUTE_XML(getTargetNestedNameDecl(), "target_nested_namespace_decl")
  ATTRIBUTE_XML(isTypeName(), "is_typename")
END_NODE_XML

//===----------------------------------------------------------------------===//
#undef NODE_XML
#undef ID_ATTRIBUTE_XML
#undef TYPE_ATTRIBUTE_XML
#undef ATTRIBUTE_XML
#undef ATTRIBUTE_SPECIAL_XML
#undef ATTRIBUTE_OPT_XML
#undef ATTRIBUTE_ENUM_XML
#undef ATTRIBUTE_ENUM_OPT_XML
#undef ATTRIBUTE_FILE_LOCATION_XML
#undef ENUM_XML
#undef END_ENUM_XML
#undef END_NODE_XML
#undef SUB_NODE_XML
#undef SUB_NODE_SEQUENCE_XML
#undef SUB_NODE_OPT_XML
#undef SUB_NODE_FN_BODY_XML