D22217: Pass extra build flags to compiler for parsing.
Aaron Puchert
noreply at phabricator.kde.org
Wed Jul 3 01:04:27 BST 2019
aaronpuchert added inline comments.
INLINE COMMENTS
> gcclikecompiler.cpp:42-45
> + const QRegularExpression regexp(QStringLiteral("(^|\\s)-x\\S+"));
> + auto result = regexp.match(arguments);
> + if (result.hasMatch())
> + return QStringLiteral("");
I don't think we need this, since later options always overwrite earlier ones. So if the build system should specify the language manually (which is very unlikely, I've never seen that), and we end with something like `-xc -xc++`, then the latter option overrides the former and the file is read as C++. Both Clang and GCC do that:
$ clang -fsyntax-only -xc -xc++ - <<<'class X {};'
$ gcc -fsyntax-only -xc -xc++ - <<<'class X {};'
> gcclikecompiler.cpp:75-80
> + {
> + const QRegularExpression regexp(QStringLiteral("(^|\\s)-std=\\S+"));
> + auto result = regexp.match(arguments);
> + if (result.hasMatch())
> + return QStringLiteral("");
> + }
The same applies here.
> gcclikecompiler.cpp:118
> + << languageStandard(arguments, type)
> + << arguments.split(QLatin1Char(' '), QString::SkipEmptyParts)
> + << QStringLiteral("-dM")
This is a substantial change, and it's pretty hard to estimate the impact. I'm not sure we can just pass on all arguments without further looking into them, given what can be done with compiler arguments. This might work for some projects, but break others.
I haven't written this code (although I've worked on it), but I think that if we could just pass the build system arguments one-to-one to the libclang parser, it would have been done that way in the first place.
We'd probably be better of if we continued the whitelisting approach, unless we want to be flooded with bug reports when this hits the shelves.
REPOSITORY
R32 KDevelop
REVISION DETAIL
https://phabricator.kde.org/D22217
To: bungeman, #kdevelop
Cc: aaronpuchert, kdevelop-devel, hmitonneau, christiant, glebaccon, domson, antismap, iodelay, alexeymin, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20190703/2c14d872/attachment.html>
More information about the KDevelop-devel
mailing list