Multiple Clang Frontend Actions

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Multiple Clang Frontend Actions

Murat B
Hi all,

I am implementing two clang actions derived from the class clang::PluginASTAction.
First tool analyzes the translation unit and modifies it.
Second tool extracts from the modified translation unit.

The second tool is able to extract the function declarations onto separate files, but I cannot get the modified translation unit from the first tool. It extracts from the original translation unit.

First tool creates
* class FirstConsumer : public clang::ASTConsumer
and second tool creates
* class SecondConsumer : public clang::ASTConsumer

First consumer class modifies function attributes:
* void FirstConsumer::HandleFunctionDecl(FunctionDecl *FD)
* {
*     ......
*     FD->addAttr(::new (*context) PureAttr(FD->getLocation(), *context));
*     ......
* }

Second consumer class checks function attributes:
* void SecondConsumer::HandleFunctionDecl(const FunctionDecl *FD)
* {
*    .....
*    for (Decl::attr_iterator AI = FD->attr_begin(),
*           AE = FD->attr_end(); AI != AE; AI++) {
*         if (PureAttr::classof(*AI))
*             llvm::errs() << "Pure Function\n";
*     }
*    .....
* }

The second tool does not see the modified version of the FunctionDecl. If I include the attribute check into the first tool, the tool gets new attribute information, but I would like to have two tools where one modifies the function and second one checks it.

Can anyone tell me if there is a way to do that?

I create the actions in this way in the driver:
* ....
* llvm::OwningPtr<FirstAction> firstact(new FirstAction);
* Clang.ExecuteAction(*firstact);
* llvm::OwningPtr<SecondAction> secondact(new SecondAction);
* Clang.ExecuteAction(*secondact);
* .....

Thanks for your help in advance!
Murat


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