summaryrefslogtreecommitdiffstats
path: root/src/linguist/shared/qmakeparser.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qmake: Apply modernize-use-nullptrAlessandro Portale2018-09-141-6/+6
| | | | | | | | | | Use nullptr instead of 0. Change-Id: Ib3120b9c424a274a2d4dd4c42ec5d7cd5bdead65 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io> (cherry picked from qtbase/a959a0e20695c4b38cf201d194e1ed7b0331e233) Reviewed-by: hjk <hjk@qt.io> Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* qmake: make VFS aware of exact vs. cumulative evaluationOswald Buddenhagen2018-09-141-39/+46
| | | | | | | | | | | | | | | | | | | | | sync-up with qt-creator; no effect on qmake (which has no cumulative vfs) and lupdate (which has only a cumulative vfs). comment on cherry-pick: this is actually a lot more than a cherry-pick, because the dual VFS needs to deal with the file ids which were concurrently introduced on the qmake side. Change-Id: I2c1eb16c97526fa275a1c6a2eae9266d385859ac Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Robert Loehning <robert.loehning@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> (cherry picked from qtcreator/424639ecac9d2e404d2bfaff7f46b45ed98664b8) (cherry picked from qtcreator/a8010b0fff47d903d4a1f80e3adb1a2ef41beb33) (cherry picked from qtcreator/d03fb350672d311dccc06f0bcb4da744a3c99745) (cherry picked from qtcreator/1ddfb443b686ef04cc0e28363308ce70d01f0d73) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* qmake: let QMakeVfs::readFile() report ENOFILE explicitlyOswald Buddenhagen2018-09-141-2/+3
| | | | | | | | | | | | | | | | when the QFile object is already constructed, querying whether the file exists is actually cheap, so do it right away instead of later on demand. that makes the calling code a bit cleaner. fwiw, that we need to explicitly query the file's existence at all is a result of QFile's completely useless error "codes" (which merely say which function failed, as if the caller would not know). Change-Id: Ifec39d05b1713d8128046f679287e510f10e45dc Reviewed-by: Tobias Hunger <tobias.hunger@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> (cherry picked from qtcreator/5ba32e3484ead2e35cc7732dcd59a97e7459dbfd) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* Change source identifier type in ProStringOswald Buddenhagen2018-09-141-10/+17
| | | | | | | | | | | | | | | | | | | The strings remember in which file they were created/assigned. However, this used a non-counting reference to a ProFile, which could become dangling. If a subsequent ProFile re-used the exact same address, a string's source would be mis-identified, which would be fatal in conjunction with discard_from(). Since we actually need only a unique id for comparison, let's use an integer for that. Task-number: QTBUG-62434 Started-by: Simon Hausmann <simon.hausmann@qt.io> Change-Id: I395153afaf7c835d0119690ee7f4b915e6f90d4a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> (cherry picked from qtbase/190aa94be7f5e146bef44862b974d733755cec85) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* qmake: introduce magic bypassNesting() scopeOswald Buddenhagen2018-09-141-1/+25
| | | | | | | | | will be needed by configure. Change-Id: If14e6944fe84767bd67604ecde98076f873749ef Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from qtbase/b6b44b368c6fc2df168195eaee57a2f925a29646) Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
* add discard_from() functionOswald Buddenhagen2016-10-101-3/+7
| | | | | | | | | | | this function discards all values that come from a specific file. it will be needed for configure bootstrapping, but is too obscure to document it for general use. Change-Id: I62c18aeb1847712e33d0599dbb0b90ffa1722438 Reviewed-by: Lars Knoll <lars.knoll@qt.io> (cherry picked from qtbase/12bb328bb0be8efe54aae750c21938aab4d17539) Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* make QMakeParser take a QStringRef as inputOswald Buddenhagen2016-10-101-17/+19
| | | | | | | | | | | | the only place where this actually saves a deep copy is the evaluation of if(), but as a side effect the parser is now able to deal with not null-terminated strings, which is kinda nice as well. Change-Id: Ib6d08617aa79d2f9eaecd4906d4d548f34bf377d Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtbase/ad17a35853fe21a93fc34f7b2d9262c5ac992b29) Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* qmake: eradicate Q_FOREACH loops [needing qAsConst()]Marc Mutz2016-10-101-1/+1
| | | | | | | | | | | | ... by replacing them with C++11 range-for loops. To avoid detaches of these mutable Qt containers, wrap the container in qAsConst(). Change-Id: If086bea06fe26232a7bb99fad8b09fce4dc74c27 Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com> (cherry picked from qtbase/e31541fa6f5f4df64fd44a9a895491c40b8c64b4) Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-10-011-7/+11
|\ | | | | | | Change-Id: Iaa0f82a8418fa2be387fb3da7220b88d8b776e4c
| * fix calculations of worst-case size requirements for token bufferOswald Buddenhagen2016-09-291-6/+9
| | | | | | | | | | | | | | | | Change-Id: I3aa4c736acec44f95a0a33c7baae9276568f684f Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtbase/d459a6b0e0d4f128caceaafe981ecf374bb3e420) Reviewed-by: Jake Petroules <jake.petroules@qt.io>
| * qmake: fix UB in QMakeParser::putHashStr()Marc Mutz2016-09-291-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Found by UBSan: qmake/library/qmakeparser.cpp:278:33: runtime error: null pointer passed as argument 2, which is declared to never be null Guard the call. Change-Id: I99341ab439a511f366dae9344ddcc8727c33b9b6 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtbase/1fd0d57ce3da83631423d17faadf97133f5c7835) Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Jake Petroules <jake.petroules@qt.io>
* | Updated license headers and license testsAntti Kokko2016-06-101-17/+12
|/ | | | | | | | | | | | | From Qt 5.7 -> tools & applications are licensed under GPL v3 with some exceptions, see http://blog.qt.io/blog/2016/01/13/new-agreement-with-the-kde-free-qt-foundation/ Updated license headers to use new GPL-EXCEPT header instead of LGPL21 one (in those files which will be under GPL 3 with exceptions) License header tests also updated to match current headers. Change-Id: Ia6bdacaa3c5bbc9d31334e1a0cabfe502a484dc4 Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
* QmakeProject: Fix crash on updating sourcesDaniel Teske2015-12-181-1/+24
| | | | | | | | | | | this doesn't actually do anything in linguist, as it's single-threaded. Change-Id: I9df2079087af6bd0d35dd121db6222e8a6ec9389 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtcreator/dedcd25924743e494055c1e0195aeef0f3983a1d) (cherry picked from qtcreator/b335b2a083e456e2b44b1e9454a0f4cd41e2a397) (cherry picked from qtcreator/a027cbcd7051c634a51b6029dcb8a5b4bfe8b046)
* add autotest enablers for qmake parserOswald Buddenhagen2015-12-181-0/+254
| | | | | | | | | the actual test is omitted from linguist. Change-Id: Ib3dcb6c1aaac20ca6a3bc0dc564e16ec7bd152db Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com> (cherry picked from qtbase/9d4641f56e76a21385db58f821ac929567d97a8c) Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* catch missing closing braces outside any scope as wellOswald Buddenhagen2015-12-181-1/+1
| | | | | | | | | it doesn't make a whole lot of sense, but it's possible to create braced blocks which have no semantic meaning. Change-Id: Id55dfdee1aa3fade507cbd1eb34bdffcd7eb6bff Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/9113e5677ca79e88ff4589d7d7819e2f3070e8b3)
* don't make an even number of bangs almost entirely invisibleOswald Buddenhagen2015-12-181-9/+8
| | | | | | | | | otherwise we'd silently accept this nonsensical code: !!defineTest(foo) {} Change-Id: I66b59c8a89852c6451ce8d7269a3dc66a53e3b1f Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/b7e839fbbd366863292566afbe736d7432d439ea)
* be more strict about bogus operatorsOswald Buddenhagen2015-12-181-6/+56
| | | | | | | | | we now warn about the pointless ones, and error out in cases that already were semantically bogus. Change-Id: Ifd80014af0fc53e3cc42561c4270d1dca234568f Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/73c84fb32bfb09a87d3a63b1f0c78d3f500ba20b)
* make some messages less ambiguousOswald Buddenhagen2015-12-181-3/+3
| | | | | | Change-Id: I6032fdc1c1e6b1fb852da09e47990de03966fa3c Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/7dcc2b3246bba323e8da8d1af5a4f87e82c0e9e0)
* don't write pointless TokAnd at start of control scopesOswald Buddenhagen2015-12-181-2/+8
| | | | | | | | | | | a colon after else/for is non-AND-ing, i.e., it's no logical operator, but "punctuation". therefore, putting an operator into the token stream is bogus. it didn't hurt execution, so it went unnoticed, but it still wasted some bytes and cpu cycles. Change-Id: If5578074257feed299bda1630bf0dfe72eb395ae Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/bec885380a091dc0b37b372acf88cc3d17c80779)
* factor out putOperator()Oswald Buddenhagen2015-12-181-7/+9
| | | | | | | Change-Id: I1b01e36e15dc93fc4e37597b66841d7102fa6b0d Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/bb26d1da0028d61e7f72fff3643af0c4601ab63e) Reviewed-by: hjk <hjk@theqtcompany.com>
* move parseError() call into bogusTest()Oswald Buddenhagen2015-12-181-22/+14
| | | | | | | | they come always in pairs (with one exception). Change-Id: Ia2f69a8776bd7146ff2fb18d13cc6bb5b2c71139 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/d800ac64d35bc4b35f87be3c93cb68776f0ee69e)
* make all parse errors invalidate the parse resultOswald Buddenhagen2015-12-181-11/+2
| | | | | | | | they have been semi-warnings for a long enough time now. Change-Id: I3fffd63f7b44b30d2dc18cdcd74221c10e98399d Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/704aec46230bf7ce29927bae03902e86454aecec)
* always flush scopes on closing braceOswald Buddenhagen2015-12-181-1/+2
| | | | | | | | | | | | | | without that, both the lines cond1 { cond2: VAR = val } and cond1 { cond2: else: cond3 } would yield two bogus errors: first an excess brace, and then a missing one. Change-Id: I8609106c1ad387577deec2077e2ce13507ac4d3f Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtbase/962c7ab6f8705a8fb7b60c3544d4189503c1ec17)
* don't write pointless TokFuncTerminators into the streamOswald Buddenhagen2015-12-181-1/+3
| | | | | | | | | | | | | we are transforming "magic" function calls into other structures. past that point it's wrong to keep the function argument list terminator in the token stream. this went unnoticed, because in this context it was equivalent with the expected value list terminator (which was simply never reached). Change-Id: I3dc6719273ce9d663db867f355eba682ba6ccf2c Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> (cherry picked from qtbase/da1aaed059d8a871c7f9cef3980ed85c71df7323)
* remove pointless return value from QMakeParser::read()Oswald Buddenhagen2015-12-181-7/+4
| | | | | | | | | | | it always returned true nowadays. an obvious followup effect is that the return value of parsedProBlock() doesn't need to be null-checked any more as well. Change-Id: I782785cab9b721a78a342a010921a73e642ebe7f Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com> (cherry picked from qtbase/030c3a6197da663e5d2df48b9130ef71ee22e86c)
* Update copyright headersAntti Kokko2015-02-141-7/+7
| | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Change-Id: I7f14f408e04c5c4f73a913fae153adcffbebe38f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Jani Heikkinen <jani.heikkinen@theqtcompany.com>
* Update license headers and add new license filesAntti Kokko2014-09-251-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: I23ef9591f4d9054e0b6a252ba7767baf4189aeab Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* implement simple VFS to support caching during project parsingOswald Buddenhagen2013-08-261-16/+8
| | | | | | | | | | | | sync up with qt creator. this counts as a bugfix, because it makes write_file() and cache() do something remotely useful. Change-Id: I833253f81c3159056fab2ff888f293b36cc2ef56 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> (cherry picked from qtbase/b215176da34661969015e4950815fe8297885163) (cherry picked from qtcreator/66802ef8bf7989dc025e34bf91d93576189c483c)
* use correct AND operatorOswald Buddenhagen2013-08-071-2/+2
| | | | | | | | amends 066b08fc62 and e1f3732197 Change-Id: I248c1b3b85b9857552bfba34fdb5299024bb55eb Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* complain about absent files to -pro argumentOswald Buddenhagen2013-07-291-4/+4
| | | | | | Task-number: QTBUG-30618 Change-Id: I908fc3792bdc321370e51be98adf7a9c81e37a85 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* avoid boolean argument trap: introduce QMakeParser::ParseFlagOswald Buddenhagen2013-07-291-2/+2
| | | | | Change-Id: I26ce032a1aa044e9a4da0c8708a4490b07374992 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* update size calculations for assignment statementsOswald Buddenhagen2013-05-281-4/+4
| | | | | | | | | | this was forgotten when the value lists were extended by a size hint. Change-Id: I6f9b55ed671224a9b8735c8d937f94aac4a73a42 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> (cherry picked from qtcreator/f24c9865306624c2fc150d4bd262a5c4d5a3689a) Reviewed-by: hjk <hjk121@nokiamail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* permit returning from filesOswald Buddenhagen2013-05-211-12/+17
| | | | | | | | | | this allows skipping an entire feature file if a condition is not fulfilled, without putting the whole body inside a conditional. Change-Id: I84fe9c94dda58c794fb52c3f163b40563b0db30a Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> (cherry picked from qtbase/525eb337670f61078383c20ad9be274dcf2d0928)
* don't pretend that break()/next()/return() are functionsOswald Buddenhagen2013-05-211-0/+47
| | | | | | | | | | | | | | | | it's a pretty braindead thing to implement control flow statements as (built-in) functions. as a "side effect", this fixes return() value handling for lists. (cherry picked from qtcreator/f53ed6c4b3feca59a94d4f0de8b1a7411122e30e) (cherry picked from qtcreator/f529e22ec38fb9a656d74394e484d2453cf42c69) Change-Id: I59c8efa0e4d65329327115f7f8ed20719e7f7546 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> (cherry picked from qtbase/8400896cfe3fbef7666329a2920bd0dbdd5890af) Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* improve parse error recovery pathsOswald Buddenhagen2013-05-211-4/+7
| | | | | | | | | | | | to reduce collateral damage from parse errors. (cherry picked from qtcreator/00c0d0d5e42d28e03c2846c17d3acbcd8420859d) Change-Id: Ic59700d657069d3b15372509b4bff966057d27a9 Reviewed-by: Qt Doc Bot <qt_docbot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> (cherry picked from qtbase/ae3f95a951334dee001e37c305e4d7bf91c0d1b3) Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* QMakeParser: save one ByteArray constructionhjk2013-02-061-1/+1
| | | | | | | Change-Id: I2845fdefb8b32de227f08017e0e3ad98923d1c87 Reviewed-by: hjk <hjk121@nokiamail.com> (cherry picked from qtcreator/52be02d1cbbf69d4f82c517c7b633ed3d13b1007) Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* Remove braces for single lines of conditionsOrgad Shaneh2013-02-061-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | #!/usr/bin/env ruby Dir.glob('**/*.cpp') { |file| # skip ast (excluding paste, astpath, and canv'ast'imer) next if file =~ /ast[^eip]|keywords\.|qualifiers|preprocessor|names.cpp/i s = File.read(file) next if s.include?('qlalr') orig = s.dup s.gsub!(/\n *if [^\n]*{\n[^\n]*\n\s+}(\s+else if [^\n]* {\n[^\n]*\n\s+})*(\s+else {\n[^\n]*\n\s+})?\n/m) { |m| res = $& if res =~ /^\s*(\/\/|[A-Z_]{3,})/ # C++ comment or macro (Q_UNUSED, SDEBUG), do not touch braces res else res.gsub!('} else', 'else') res.gsub!(/\n +} *\n/m, "\n") res.gsub(/ *{$/, '') end } s.gsub!(/ *$/, '') File.open(file, 'wb').write(s) if s != orig } Change-Id: I3b30ee60df0986f66c02132c65fc38a3fbb6bbdc Reviewed-by: hjk <qthjk@ovi.com> (cherry picked from qtcreator/29a93998df8405e8799ad23934a56cd99fb36403) Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-101-1/+1
| | | | | | | Change-Id: I9b11dc8309c9739955e3acea12b564d6ad608f59 Reviewed-by: Akseli Salovaara <akseli.salovaara@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Fix qmake's pro file cache to interact correctly with write_fileSimon Hausmann2012-11-051-0/+6
| | | | | | | | | | | | When writing a file with write_file() we have to inform the pro file parser cache to discard the file if it's existant in the cache, to ensure that calling include() after write_file() always works. Change-Id: I7d09269a57de55ca30b0e11dd40770de9f919f64 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> (cherry picked from qtbase/f45d6414ad6ef1d75f049a61411cd954bcae29c3) Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-251-24/+24
| | | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If89e41b25a242ff376eacdf8790957bcf499cc66 Reviewed-by: Janne Anttila <janne.anttila@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* update qmake evaluator to newest version from qt creatorOswald Buddenhagen2012-09-201-0/+1169
Change-Id: I66ec46dd87f922094f6937b50cc40e02ef08cc86 Reviewed-by: Daniel Teske <daniel.teske@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>