[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cfe-dev
Subject:    [cfe-dev] Possible bug when model-parsing multiple source files
From:       Manuel Freiberger via cfe-dev <cfe-dev () lists ! llvm ! org>
Date:       2017-04-21 19:51:01
Message-ID: trinity-9e4dd865-5257-471f-b570-43c6c5bba443-1492804261106 () 3capp-gmx-bs26
[Download RAW message or body]

Hi all,

I'm toying around with libTooling and think there is a bug in 
CompilerInstance::ExecuteAction(FrontendAction &Act)
when FrontendAction::isModelParsingAction() is true.

The issue is that ExecuteAction() loops over all input source files and
executes FrontendAction::BeginSourceFile(), FrontendAction::Execute() and
FrontendAction::EndSourceFile() on them.

For model-parsing actions, no new AST context is created in BeginSourceFile() because
it re-uses the existing one. However, EndSourceFile() unconditionally resets the 
AST-context in the CompilerInstance (either via CI.resetAndLeakASTContext() or 
CI.setASTContext(nullptr) --- depending on DisableFree) even if the action is a 
model-parsing one.

So when the second source file is processed, the CompilerInstance no longer has an
AST which leads to a crash as soon as the new sema instance is to be created.

To fix this, at least the CompilerInstance's AST must not be reset in EndSourceFile()
when isModelParsingAction() is true. I'm not completely sure if other parts of the
CompilerInstance should survive too.

IMHO it would also be nice, if FrontendAction::BeginSourceFile() and 
FrontendAction::EndSourceFile() were virtual (probably FrontendAction::Execute() as
well). This would greatly simplify the setup of a CompilerInstance when one needs
to parse into an already existing AST context.

Thanks,
Manuel
_______________________________________________
cfe-dev mailing list
cfe-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic