diff options
Diffstat (limited to 'tools/libclang/CIndex.cpp')
-rw-r--r-- | tools/libclang/CIndex.cpp | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 7fb944ddd3..df8adb419e 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -5676,7 +5676,35 @@ CXFile clang_getIncludedFile(CXCursor cursor) { InclusionDirective *ID = getCursorInclusionDirective(cursor); return (void *)ID->getFile(); } - + +CXSourceRange clang_Cursor_getCommentRange(CXCursor C) { + if (!clang_isDeclaration(C.kind)) + return clang_getNullRange(); + + const Decl *D = getCursorDecl(C); + ASTContext &Context = getCursorContext(C); + const RawComment *RC = Context.getRawCommentForDecl(D); + if (!RC) + return clang_getNullRange(); + + return cxloc::translateSourceRange(Context, RC->getSourceRange()); +} + +CXString clang_Cursor_getRawCommentText(CXCursor C) { + if (!clang_isDeclaration(C.kind)) + return createCXString((const char *) NULL); + + const Decl *D = getCursorDecl(C); + ASTContext &Context = getCursorContext(C); + const RawComment *RC = Context.getRawCommentForDecl(D); + StringRef RawText = RC ? RC->getRawText(Context.getSourceManager()) : + StringRef(); + + // Don't duplicate the string because RawText points directly into source + // code. + return createCXString(RawText, false); +} + } // end: extern "C" |