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