On Sep 12, 2012, at 11:41 PM, Ted Kremenek <[email protected]> wrote:

> Author: kremenek
> Date: Thu Sep 13 01:41:18 2012
> New Revision: 163778
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=163778&view=rev
> Log:
> Conditionally parse documentation comments in system headers by
> passing -fretain-comments-from-system-headers.  By default, the
> compiler no longer parses such documentation comments, as they
> can result in a noticeable compile time/PCH slowdown.
> 
> Fixes <rdar://problem/11860820>.

I hope this isn't needed in the long term. It would be far better if we could 
make the fast path fast enough that we can at least have comments available in 
the AST, but not attached or parsed in system headers (since the documentation 
warnings wouldn't be emitted anyway).

        - Doug

> Modified:
>    cfe/trunk/include/clang/AST/ASTContext.h
>    cfe/trunk/include/clang/Basic/LangOptions.def
>    cfe/trunk/include/clang/Driver/Options.td
>    cfe/trunk/lib/Driver/Tools.cpp
>    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>    cfe/trunk/lib/Sema/Sema.cpp
> 
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Thu Sep 13 01:41:18 2012
> @@ -514,6 +514,8 @@
>   }
> 
>   void addComment(const RawComment &RC) {
> +    assert(LangOpts.RetainCommentsFromSystemHeaders ||
> +           !SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin()));
>     Comments.addComment(RC, BumpAlloc);
>   }
> 
> 
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Thu Sep 13 01:41:18 2012
> @@ -166,6 +166,8 @@
> BENIGN_LANGOPT(EmitMicrosoftInlineAsm , 1, 0, 
>                "Enable emission of MS-style inline assembly.")
> 
> +BENIGN_LANGOPT(RetainCommentsFromSystemHeaders, 1, 0, "retain documentation 
> comments from system headers in the AST")
> +
> #undef LANGOPT
> #undef VALUE_LANGOPT
> #undef BENIGN_LANGOPT
> 
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Thu Sep 13 01:41:18 2012
> @@ -468,6 +468,7 @@
>   HelpText<"Specify the module cache path">;
> def fmodules : Flag <"-fmodules">, Group<f_Group>, 
> Flags<[NoForward,CC1Option]>,
>   HelpText<"Enable the 'modules' language feature">;
> +def fretain_comments_from_system_headers : 
> Flag<"-fretain-comments-from-system-headers">, Group<f_Group>, 
> Flags<[CC1Option]>;
> 
> def fmudflapth : Flag<"-fmudflapth">, Group<f_Group>;
> def fmudflap : Flag<"-fmudflap">, Group<f_Group>;
> 
> Modified: cfe/trunk/lib/Driver/Tools.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Driver/Tools.cpp (original)
> +++ cfe/trunk/lib/Driver/Tools.cpp Thu Sep 13 01:41:18 2012
> @@ -2785,6 +2785,9 @@
>     CmdArgs.push_back(Args.MakeArgString(A->getValue(Args)));
>   }
> 
> +  if (Args.hasArg(options::OPT_fretain_comments_from_system_headers))
> +    CmdArgs.push_back("-fretain-comments-from-system-headers");
> +
>   // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM 
> option
>   // parser.
>   Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
> 
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Thu Sep 13 01:41:18 2012
> @@ -2151,6 +2151,9 @@
> 
>   Opts.EmitMicrosoftInlineAsm = 
> Args.hasArg(OPT_fenable_experimental_ms_inline_asm);
> 
> +  Opts.RetainCommentsFromSystemHeaders =
> +      Args.hasArg(OPT_fretain_comments_from_system_headers);
> +
>   unsigned SSP = Args.getLastArgIntValue(OPT_stack_protector, 0, Diags);
>   switch (SSP) {
>   default:
> 
> Modified: cfe/trunk/lib/Sema/Sema.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.cpp?rev=163778&r1=163777&r2=163778&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/Sema.cpp (original)
> +++ cfe/trunk/lib/Sema/Sema.cpp Thu Sep 13 01:41:18 2012
> @@ -1026,6 +1026,9 @@
> }
> 
> void Sema::ActOnComment(SourceRange Comment) {
> +  if (!LangOpts.RetainCommentsFromSystemHeaders &&
> +      SourceMgr.isInSystemHeader(Comment.getBegin()))
> +    return;
>   RawComment RC(SourceMgr, Comment);
>   if (RC.isAlmostTrailingComment()) {
>     SourceRange MagicMarkerRange(Comment.getBegin(),
> 
> 
> _______________________________________________
> cfe-commits mailing list
> [email protected]
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to