From 113a55fb4314b0e025ffc9e95769eb5f478062ef Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Mon, 28 Apr 2014 02:39:27 +0000 Subject: libclang: split out the documentation comment API It's possible that the "comment AST" may be replaced or split out in the midterm, any anyway this makes the headers easier to read. Developers don't currently need to include "clang-c/Documentation.h" explicitly and there's no macro to test for availability yet. The raw comment and brief comment accessors have been kept in Index.h though brief support may also move here as a separate proposal. This is not a deprecation, just a gentle separation of concerns as we look to simplify the built-in representation of comment nodes and support external comment processors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207392 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/CIndex.cpp | 12 ------------ tools/libclang/CXComment.cpp | 14 ++++++++++++++ tools/libclang/CXComment.h | 1 + 3 files changed, 15 insertions(+), 12 deletions(-) (limited to 'tools/libclang') diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index f3c9f2fa44..26b3bf16af 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -15,7 +15,6 @@ #include "CIndexer.h" #include "CIndexDiagnostic.h" #include "CLog.h" -#include "CXComment.h" #include "CXCursor.h" #include "CXSourceLocation.h" #include "CXString.h" @@ -6312,17 +6311,6 @@ CXString clang_Cursor_getBriefCommentText(CXCursor C) { return cxstring::createNull(); } -CXComment clang_Cursor_getParsedComment(CXCursor C) { - if (!clang_isDeclaration(C.kind)) - return cxcomment::createCXComment(NULL, NULL); - - const Decl *D = getCursorDecl(C); - const ASTContext &Context = getCursorContext(C); - const comments::FullComment *FC = Context.getCommentForDecl(D, /*PP=*/ NULL); - - return cxcomment::createCXComment(FC, getCursorTU(C)); -} - CXModule clang_Cursor_getModule(CXCursor C) { if (C.kind == CXCursor_ModuleImportDecl) { if (const ImportDecl *ImportD = diff --git a/tools/libclang/CXComment.cpp b/tools/libclang/CXComment.cpp index 2c4f269f9e..8fb7c0a5c4 100644 --- a/tools/libclang/CXComment.cpp +++ b/tools/libclang/CXComment.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "clang-c/Index.h" +#include "clang-c/Documentation.h" #include "CXComment.h" #include "CXCursor.h" #include "CXString.h" @@ -28,6 +29,19 @@ using namespace clang::cxcomment; extern "C" { +CXComment clang_Cursor_getParsedComment(CXCursor C) { + using namespace clang::cxcursor; + + if (!clang_isDeclaration(C.kind)) + return createCXComment(NULL, NULL); + + const Decl *D = getCursorDecl(C); + const ASTContext &Context = getCursorContext(C); + const FullComment *FC = Context.getCommentForDecl(D, /*PP=*/NULL); + + return createCXComment(FC, getCursorTU(C)); +} + enum CXCommentKind clang_Comment_getKind(CXComment CXC) { const Comment *C = getASTNode(CXC); if (!C) diff --git a/tools/libclang/CXComment.h b/tools/libclang/CXComment.h index 1e2561d585..606ee26bb6 100644 --- a/tools/libclang/CXComment.h +++ b/tools/libclang/CXComment.h @@ -16,6 +16,7 @@ #include "CXTranslationUnit.h" #include "clang-c/Index.h" +#include "clang-c/Documentation.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Comment.h" #include "clang/Frontend/ASTUnit.h" -- cgit v1.2.3