diff options
| author | Ted Kremenek <kremenek@apple.com> | 2012-09-13 06:41:18 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2012-09-13 06:41:18 +0000 |
| commit | b47e6bc597466438fcb960ebcd34eec54bc52edf (patch) | |
| tree | 161127991c2c7c908f275806da4e4b82bc16ee22 /clang | |
| parent | 17674ec8c6631c4b5d645ccf3ad1e39b633095c4 (diff) | |
| download | bcm5719-llvm-b47e6bc597466438fcb960ebcd34eec54bc52edf.tar.gz bcm5719-llvm-b47e6bc597466438fcb960ebcd34eec54bc52edf.zip | |
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>.
llvm-svn: 163778
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/include/clang/AST/ASTContext.h | 2 | ||||
| -rw-r--r-- | clang/include/clang/Basic/LangOptions.def | 2 | ||||
| -rw-r--r-- | clang/include/clang/Driver/Options.td | 1 | ||||
| -rw-r--r-- | clang/lib/Driver/Tools.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 3 |
6 files changed, 14 insertions, 0 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h index 08975822055..5555e97a8c9 100644 --- a/clang/include/clang/AST/ASTContext.h +++ b/clang/include/clang/AST/ASTContext.h @@ -514,6 +514,8 @@ public: } void addComment(const RawComment &RC) { + assert(LangOpts.RetainCommentsFromSystemHeaders || + !SourceMgr.isInSystemHeader(RC.getSourceRange().getBegin())); Comments.addComment(RC, BumpAlloc); } diff --git a/clang/include/clang/Basic/LangOptions.def b/clang/include/clang/Basic/LangOptions.def index 8f94ade80fc..0ef4ad2c190 100644 --- a/clang/include/clang/Basic/LangOptions.def +++ b/clang/include/clang/Basic/LangOptions.def @@ -166,6 +166,8 @@ LANGOPT(ApplePragmaPack, 1, 0, "Apple gcc-compatible #pragma pack handling") 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 diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index c7698a28f91..6a5c42b3e1b 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -468,6 +468,7 @@ def fmodule_cache_path : Separate<"-fmodule-cache-path">, Group<i_Group>, 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>; diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index c10df6fc634..f26ed159d1e 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -2785,6 +2785,9 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, 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); diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 6d6dbfcc286..6d34425e130 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -2151,6 +2151,9 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args, InputKind IK, 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: diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index fd57bbc237d..bd7c8515f64 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1026,6 +1026,9 @@ LambdaScopeInfo *Sema::getCurLambda() { } void Sema::ActOnComment(SourceRange Comment) { + if (!LangOpts.RetainCommentsFromSystemHeaders && + SourceMgr.isInSystemHeader(Comment.getBegin())) + return; RawComment RC(SourceMgr, Comment); if (RC.isAlmostTrailingComment()) { SourceRange MagicMarkerRange(Comment.getBegin(), |

