1*67e74705SXin Li //===- CXComment.h - Routines for manipulating CXComments -----------------===// 2*67e74705SXin Li // 3*67e74705SXin Li // The LLVM Compiler Infrastructure 4*67e74705SXin Li // 5*67e74705SXin Li // This file is distributed under the University of Illinois Open Source 6*67e74705SXin Li // License. See LICENSE.TXT for details. 7*67e74705SXin Li // 8*67e74705SXin Li //===----------------------------------------------------------------------===// 9*67e74705SXin Li // 10*67e74705SXin Li // This file defines routines for manipulating CXComments. 11*67e74705SXin Li // 12*67e74705SXin Li //===----------------------------------------------------------------------===// 13*67e74705SXin Li 14*67e74705SXin Li #ifndef LLVM_CLANG_TOOLS_LIBCLANG_CXCOMMENT_H 15*67e74705SXin Li #define LLVM_CLANG_TOOLS_LIBCLANG_CXCOMMENT_H 16*67e74705SXin Li 17*67e74705SXin Li #include "CXTranslationUnit.h" 18*67e74705SXin Li #include "clang-c/Documentation.h" 19*67e74705SXin Li #include "clang-c/Index.h" 20*67e74705SXin Li #include "clang/AST/ASTContext.h" 21*67e74705SXin Li #include "clang/AST/Comment.h" 22*67e74705SXin Li #include "clang/Frontend/ASTUnit.h" 23*67e74705SXin Li 24*67e74705SXin Li namespace clang { 25*67e74705SXin Li namespace comments { 26*67e74705SXin Li class CommandTraits; 27*67e74705SXin Li } 28*67e74705SXin Li 29*67e74705SXin Li namespace cxcomment { 30*67e74705SXin Li createCXComment(const comments::Comment * C,CXTranslationUnit TU)31*67e74705SXin Listatic inline CXComment createCXComment(const comments::Comment *C, 32*67e74705SXin Li CXTranslationUnit TU) { 33*67e74705SXin Li CXComment Result; 34*67e74705SXin Li Result.ASTNode = C; 35*67e74705SXin Li Result.TranslationUnit = TU; 36*67e74705SXin Li return Result; 37*67e74705SXin Li } 38*67e74705SXin Li getASTNode(CXComment CXC)39*67e74705SXin Listatic inline const comments::Comment *getASTNode(CXComment CXC) { 40*67e74705SXin Li return static_cast<const comments::Comment *>(CXC.ASTNode); 41*67e74705SXin Li } 42*67e74705SXin Li 43*67e74705SXin Li template<typename T> getASTNodeAs(CXComment CXC)44*67e74705SXin Listatic inline const T *getASTNodeAs(CXComment CXC) { 45*67e74705SXin Li const comments::Comment *C = getASTNode(CXC); 46*67e74705SXin Li if (!C) 47*67e74705SXin Li return nullptr; 48*67e74705SXin Li 49*67e74705SXin Li return dyn_cast<T>(C); 50*67e74705SXin Li } 51*67e74705SXin Li getASTContext(CXComment CXC)52*67e74705SXin Listatic inline ASTContext &getASTContext(CXComment CXC) { 53*67e74705SXin Li return cxtu::getASTUnit(CXC.TranslationUnit)->getASTContext(); 54*67e74705SXin Li } 55*67e74705SXin Li getCommandTraits(CXComment CXC)56*67e74705SXin Listatic inline comments::CommandTraits &getCommandTraits(CXComment CXC) { 57*67e74705SXin Li return getASTContext(CXC).getCommentCommandTraits(); 58*67e74705SXin Li } 59*67e74705SXin Li 60*67e74705SXin Li } // end namespace cxcomment 61*67e74705SXin Li } // end namespace clang 62*67e74705SXin Li 63*67e74705SXin Li #endif 64*67e74705SXin Li 65