[cfe-dev] The QtReslot Clang plugin
Manuel Klimek via cfe-dev
cfe-dev at lists.llvm.org
Wed Feb 15 02:00:25 PST 2017
Both of these projects duplicate a lot of code from clang-tidy and the AST
matcher infrastructure in clang.
I'd be curious what the reasons are to not use those, so we can try to
address them :)
Browsing over the code, I think a large percentage of it could be saved.
For example:
static CXXMethodDecl* isArgMethod(FunctionDecl *func)
{
if (!func)
return nullptr;
CXXMethodDecl *method = dyn_cast<CXXMethodDecl>(func);
if (!method || method->getNameAsString() != "arg")
return nullptr;
CXXRecordDecl *record = method->getParent();
if (!record || record->getNameAsString() != "QString")
return nullptr;
return method;
}
would become the AST matcher:
cxxMethodDecl(hasName("QString::arg"))
Generally, you could find calls to QString::arg with something like:
callExpr(callee(cxxMethodDecl(hasName("QString::arg"))))
Cheers,
/Manuel
On Tue, Feb 14, 2017 at 11:29 PM Kevin Funk via cfe-dev <
cfe-dev at lists.llvm.org> wrote:
> On Tuesday, 14 February 2017 20:33:15 CET Richard Braun via cfe-dev wrote:
> > Hello,
> >
> > During work on an internal Qt-based project at Novasys-Ingenierie,
> > a Clang plugin was written to convert string-based signals and slots
> > to the Qt5 syntax. The plugin has since been pushed to Github [1]
> > in the hope it will be useful to others facing similar issues.
>
> Heya Richard,
>
> just for the sake of making you aware of existing tools (to save work &
> share
> ideas): there already is a Qt oriented Clang-based code checker called
> Clazy
> mainly developed by one of my colleagues at KDAB.
>
> Clazy allows all sorts of checking & refactoring in Qt code. It also has a
> check for 'old-style-connect' & provides fixits for it: IOW, it will
> transform
> the code to new-style-connect statements if desired.
>
> Worth having a look, maybe you want to contribute some of your code there
> instead so it gets available to a wider audience:
> https://github.com/KDE/clazy
>
> Clazy has already been used to refactor *lots* of code in KDE land
> automatically.
>
> Hope that helps,
> Kevin
>
> PS: CC'ed Sergio, the main author.
>
> --
> Kevin Funk | kfunk at kde.org | http://kfunk.org
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170215/25bf7966/attachment.html>
More information about the cfe-dev
mailing list