[cfe-commits] r166130 - in /cfe/trunk: bindings/xml/comment-xml-schema.rng include/clang/AST/Comment.h include/clang/AST/PrettyPrinter.h lib/AST/Comment.cpp lib/AST/DeclPrinter.cpp test/Index/annotate-comments-availability-attrs.cpp test/Index/an

NAKAMURA Takumi geek4civic at gmail.com
Wed Oct 17 18:45:01 PDT 2012


2012/10/18 Fariborz Jahanian <fjahanian at apple.com>:
> Author: fjahanian
> Date: Wed Oct 17 16:58:03 2012
> New Revision: 166130
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166130&view=rev
> Log:
> [Doc parsing]: This patch adds <Declaration> tag to
> XML comment for declarations which pretty-prints
> declaration. I had to XFAIL one test annotate-comments.cpp.
> This test is currently unmaintainable as written.
> Dmitri G., can you see what we can do about this test.
> We should change this test such that adding a new tag does not wreck
> havoc to the test.
>
> Modified:
>     cfe/trunk/bindings/xml/comment-xml-schema.rng
>     cfe/trunk/include/clang/AST/Comment.h
>     cfe/trunk/include/clang/AST/PrettyPrinter.h
>     cfe/trunk/lib/AST/Comment.cpp
>     cfe/trunk/lib/AST/DeclPrinter.cpp
>     cfe/trunk/test/Index/annotate-comments-availability-attrs.cpp
>     cfe/trunk/test/Index/annotate-comments.cpp
>     cfe/trunk/test/Index/overriding-ftemplate-comments.cpp
>     cfe/trunk/test/Index/overriding-method-comments.mm
>     cfe/trunk/tools/libclang/CXComment.cpp

> Modified: cfe/trunk/tools/libclang/CXComment.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXComment.cpp?rev=166130&r1=166129&r2=166130&view=diff
> ==============================================================================
> --- cfe/trunk/tools/libclang/CXComment.cpp (original)
> +++ cfe/trunk/tools/libclang/CXComment.cpp Wed Oct 17 16:58:03 2012
> @@ -16,6 +16,7 @@
>  #include "CXComment.h"
>  #include "CXCursor.h"
>
> +#include "clang/AST/PrettyPrinter.h"
>  #include "clang/AST/CommentVisitor.h"
>  #include "clang/AST/CommentCommandTraits.h"
>  #include "clang/AST/Decl.h"
> @@ -1027,6 +1028,20 @@
>    Result << "</Verbatim>";
>  }
>
> +static StringRef getSourceTextOfDeclaration(const DeclInfo *ThisDecl) {
> +
> +  ASTContext &Context = ThisDecl->CurrentDecl->getASTContext();
> +  const LangOptions &LangOpts = Context.getLangOpts();
> +  std::string SStr;
> +  llvm::raw_string_ostream S(SStr);
> +  PrintingPolicy PPolicy(LangOpts);
> +  PPolicy.SuppressAttributes = true;
> +  PPolicy.TerseOutput = true;
> +  ThisDecl->CurrentDecl->print(S, PPolicy,
> +                               /*Indentation*/0, /*PrintInstantiation*/true);
> +  return S.str();
> +}
> +

Don't escape local std::string with StringRef. Fixed in r166163.



More information about the cfe-commits mailing list