[cfe-commits] [Patch] Adding flag to libclang to skip parsing method bodies
Erik Verbruggen
erikjv at me.com
Thu Apr 12 03:18:27 PDT 2012
On Apr 10, 2012, at 15:30, Douglas Gregor wrote:
>
> On Apr 6, 2012, at 11:50 AM, Erik Verbruggen <erikjv at me.com> wrote:
>
>>
>> On Mar 14, 2012, at 17:43, Erik Verbruggen wrote:
>>
>>>
>>>
>>> On 14 mrt. 2012, at 17:34, Douglas Gregor <dgregor at apple.com> wrote:
>>>
>>>>
>>>> On Dec 14, 2011, at 7:51 AM, Erik Verbruggen wrote:
>>>>
>>>>> Attached is a patch to have the parser skip method bodies. The beef of the patch is propagating the flag down to the constructor of the Parser class. I also changed the code-completion (which also uses it) to set this flag.
>>>>
>>>>
>>>> This patch seems to have gotten dropped on the floor. I'm fine with this patch (although I suspect it's gone rather stale).
>>>
>>> It's very stale. I'll revisit it when I have time and send a new patch.
>>
>>
>> Attached is a revised/updated version of the patch which applies cleanly against trunk rev. #154168.
>
> Two minor comments, then I think this can go in
>
> First, please add a test to the test suite that makes use of this feature (verifying that function bodies *don't* get parsed)
Done.
> Second, it doesn't look like SkipFunctionBodies will always get set when code-completion is on, with rather unfortunate performance consequences. For example, here:
>
> @@ -38,7 +38,8 @@ using namespace clang;
> void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
> ASTContext &Ctx, bool PrintStats,
> TranslationUnitKind TUKind,
> - CodeCompleteConsumer *CompletionConsumer) {
> + CodeCompleteConsumer *CompletionConsumer,
> + bool SkipFunctionBodies) {
>
> OwningPtr<Sema> S(new Sema(PP, Ctx, *Consumer,
> TUKind,
> @@ -47,10 +48,10 @@ void clang::ParseAST(Preprocessor &PP, ASTConsumer *Consumer,
> // Recover resources if we crash before exiting this method.
> llvm::CrashRecoveryContextCleanupRegistrar<Sema> CleaupSema(S.get());
>
> - ParseAST(*S.get(), PrintStats);
> + ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
> }
>
> it seems that we should either have
>
> if (CompletionConsumer) SkipFunctionBodies = true;
>
> or, more directly, have CompilerInstance ensure that, when code completion is turned on, SkipFunctionBodies is enabled.
That if got dropped when I updated the patch. I added it to CompilerInstance::setCodeCompletionConsumer.
> (Also, there's a typo 'CleaupSema' above).
Fixed that one too (and another occurrence). Submitted as r154584.
-- Erik.
More information about the cfe-commits
mailing list