src/compiler/preprocessor


Log

Author Commit Date CI Message
Jamie Madill f39a9659 2022-09-09T10:09:58 Update flex/bison binaries. These binaries were updated using update_flex_bison_binaries.py. Please see instructions in tools/flex-bison/README.md. flex is at version 2.6.4. bison is at version 3.8.2. Bug: None Change-Id: Ia3189b678fc8ddacdf14bbfd3f4750f938d32ac3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3886807 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Eddie Hatfield 91976352 2022-06-21T15:41:02 Use C++17 attributes instead of custom macros Bug: angleproject:6747 Change-Id: Iad6c7cd8a18d028e01da49b647c5d01af11e0522 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3718999 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 7a85d114 2022-03-25T15:01:17 Use [[nodiscard]] on RAII classes Scoped* classes provide an RAII way of adding cleanup/restore state/etc in a robust way. Unfortunatley, it's very easy to mistakenly leave the variable name, leading to the destructor being called immediately instead of at the end of the scope: { ScopedX(parameters); // instead of ScopedX x(parameters); // Code here is run after destructor } The [[nodiscard]] attribute, if specified on the ScopedX class would lead to a warning (turned to error with -Werror). This change does that for classes named *Scoped* in ANGLE. Bug: chromium:1103817 Change-Id: I65c9922c9b4eba1f9c033e093fe8fe534648ab62 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3552092 Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Hans Wennborg 0c23c72b 2022-03-25T17:19:37 Suppress -Wunused-but-set-variable in Bison-generated code Recent Clang versions have enhanced the warning, causing it to fire in preprocessor_tab_autogen.cpp and glslang_tab_autogen.cpp. Since those are generated by Bison, we can't fix the code and instead should suppress the warning there. Bug: chromium:1309955 Change-Id: I31aa83571162310bef47a7ce84841446713a2d04 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3550200 Commit-Queue: Hans Wennborg <hans@chromium.org> Auto-Submit: Hans Wennborg <hans@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Amirali Abdolrashidi e47a67e4 2022-02-22T11:40:23 Update Python scripts to run with Python 3 * Updated the scripts used in run_code_generation.py so they could be run with Python 3 with no errors. Bug: angleproject:5707 Change-Id: Iad7ff61a34ce53b6d54821cdd53ee846dc4afc3c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3482156 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Geoff Lang e0619360 2020-11-18T11:13:11 Skip tracking non-preprocessor tokens in disabled if-blocks ESSL1 states that it is an error to have a non-preprocessor token before an extension pragma but ANGLE would mark a non-preprocessor token as seen even if it was in a disabled if-block. Bug: b/161716126 Change-Id: I782224bee211bc7214a2d1d98d4829b4c94101bd Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2547205 Reviewed-by: Cody Northrop <cnorthrop@google.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
James Darpinian d6053daa 2019-12-05T17:46:23 Remove tabs from source files. WebKit's Subversion repo refuses to commit source files that contain tabs. Bug: angleproject:3439 Change-Id: I0a804bcfa0375a98e19945e20297c90d31106827 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1954410 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Shahbaz Youssefi 5efb36b9 2019-11-25T16:14:55 Automatically call flex/bison if necessary ANGLE translator's parser code generation is changed to use the binaries of flex/bison stored in the cloud. scripts/run_code_generation.py now automatically runs these files if the input files change. Bug: angleproject:3419 Change-Id: Icce4247f93b27baf8ee12dbb16112fa2cc98c111 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1940572 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
Tobin Ehlis 93121f36 2019-10-17T08:18:16 Make invalid extension directive a CHROMEOS warning This change allows extension directive after ESSL1.0 non-preprocessor tokens on CHROMEOS. CHROMEOS kiosks have a video player that violates this spec requirement so just flagging as a warning to prevent failed video playback. Added ANGLE_PLATFORM_CHROMEOS define to build config in order to only make this a warning on CHROMEOS. Split the ESSL1 & ESSL3 cases back out as ESSL3 had always been an error on all platforms in the past and so want to keep it that way. Bug: 1003005 Bug: angleproject:4023 Change-Id: Ia931b3a8dad82dbda4c9c9e49a9c1090116397b5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1866464 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
James Darpinian 153f3c22 2019-08-16T15:24:30 Miscellaneous build fixes for WebKit Add a USE_SYSTEM_EGL define to allow compilation on Unix systems without X11. Feature detect __popcnt using Microsoft-specific _MSC_VER rather than _M_X64/_M_IX86, which can be set by the Dinkumware stdlib on non-Microsoft systems. Apple's clang is too old to have -Wextra-semi-stmt Ran generate_parser.sh using Cygwin64 bison 3.0.4, flex 2.6.4 Bug: 3439 Change-Id: Ie0d01a112a17f70ef60c120063a958b8f1a094f4 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1759135 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org>
Stuart Morgan 9d737966 2019-08-14T12:25:12 Standardize copyright notices to project style For all "ANGLE Project" copyrights, standardize to the format specified by the style guide. Changes: - "Copyright (c)" and "Copyright(c)" changed to just "Copyright". - Removed the second half of date ranges ("Y1Y1-Y2Y2"->"Y1Y1"). - Fixed a small number of files that had no copyright date using the initial commit year from the version control history. - Fixed one instance of copyright being "The ANGLE Project" rather than "The ANGLE Project Authors" These changes are applied both to the copyright of source file, and where applicable to copyright statements that are generated by templates. BUG=angleproject:3811 Change-Id: I973dd65e4ef9deeba232d5be74c768256a0eb2e5 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1754397 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
James Darpinian efa898ac 2019-08-07T17:05:35 Enable some compiler warnings used by WebKit. This will make it easier to roll ANGLE in WebKit. Bug: angleproject:3439 Change-Id: Icd4a5a2d5dcabb6cf13d4b46a7547f49610fa4b3 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1743057 Commit-Queue: James Darpinian <jdarpinian@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Clemen Deng 1d672749 2019-07-08T15:42:05 WGL implemetation for OpenGL tutorial Fixes to make WGL implementation work with OpenGL tutorial - Give directive parser the correct shader spec when on Desktop GL - Minor changes to parse Desktop GL shaders - Moved clientType parameter from Context to Context->mState - Minor fixes to WGL functions Bug: angleproject:3666 Change-Id: I01ddb828f6d581ad445f49942589436849eae5d9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1693244 Commit-Queue: Clemen Deng <clemendeng@google.com> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Tobin Ehlis d7013c03 2019-06-17T09:27:18 Merge ESSL pre-processsor token errors In both the ESSL 1.00 & 3.00 specifications having an extension directive after a pre-processor token is an error. Merging those two enum cases to be a single case. WebGL is handled as a separate warning case for any shader version before 3.00. Also this change now correctly marks 1.00 shaders that break this rule to be invalid so the ExtensionAfterNonPreProcessorTokenESSL1 test no longer expects handleExtension() to be called. BUG=chromium:971660 Change-Id: I37b10cc0fb3a0efd6200a478171e005a96478255 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1661395 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
Tobin Ehlis 35b25fc6 2019-06-07T11:54:36 For WebGL warn on late extension directive A previous change based on ESSL 1.00 spec had made it an error in all cases when an extension directive appeared in a shader after the first non-preprocessor token. However, this is incorrect for WebGL 1.0 so adding warning case for WebGL. BUG=chromium:971660 Change-Id: I026fe60e8b1876de65b001b676f7a0552739a20c Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1648661 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kai Ninomiya <kainino@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
Tobin Ehlis 9af10e8a 2019-04-11T16:20:57 Incorrectly placed extension directive is an error The ESSL 1.00 spec states "...the extension directives must occur before any non-preprocessor tokens." This change makes the occurance of an extension directive after non-preprocessor tokens a compilation error. Bug: angleproject:3285 Change-Id: I9f8631366151c92fb6d8b4408596917012d9a3e9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1565411 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Tobin Ehlis <tobine@google.com>
Jonah Ryan-Davis d4c09dd3 2019-01-29T11:22:54 Fix unnecessary copy of for loop variables in ANGLE Bug: angleproject:3075 Change-Id: I34dd5d4ecded6def5a2b46369277312af0de7c8c Reviewed-on: https://chromium-review.googlesource.com/c/1443572 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Jonah Ryan-Davis <jonahr@google.com>
Jamie Madill c09ae15c 2019-02-01T14:16:32 Enable -Wextra-semi and -Wextra-semi-stmt. This will prevent users from accidentally making semicolon errors in the future. Bug: chromium:926235 Change-Id: I79a6fa376fb1ad8f0fcf1b65b1f572a035d1f4e9 Reviewed-on: https://chromium-review.googlesource.com/c/1446493 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill b980c563 2018-11-27T11:34:27 Reformat all cpp and h files. This applies git cl format --full to all ANGLE sources. Bug: angleproject:2986 Change-Id: Ib504e618c1589332a37e97696cdc3515d739308f Reviewed-on: https://chromium-review.googlesource.com/c/1351367 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Jamie Madill c3bef3e7 2018-10-03T07:35:09 Allow 'defined' in define in non-WebGL. This is needed to pass dEQP conformance. Several of the harder dEQP tests around this behaviour are excluded from the mustpass list. This is presumably because the behaviours weren't implemented portably. Nevertheless we need to support conformant behaviour for GLES 2.0 Contexts for the most simple uses. This also leaves the error behaviour intact for WebGL specs. Bug: angleproject:1335 Change-Id: Ia80b4f71475efa928488ee6c2ee35c566d4602d4 Reviewed-on: https://chromium-review.googlesource.com/c/1242013 Reviewed-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho c3907efa 2018-06-08T13:03:15 Always use custom float parsing in GLSL We now always use custom parsing code for parsing floats in GLSL shaders. Previously this code was only used in corner cases that stringstream parsing did not handle according to the GLSL spec. This is slightly faster in compiler perftests, and results in a smaller binary as well. Some new test cases are added to make sure that the custom float parsing behaves correctly. BUG=chromium:849245 TEST=angle_unittests, angle_perftests Change-Id: I2a88ec6a8b427016e34519d72bc98216947a4c64 Reviewed-on: https://chromium-review.googlesource.com/1092697 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jeff Gilbert 79216620 2018-05-29T19:19:54 Use stringstream with locale override. Add test for compiling float literals in locales with comma decimal separators. Handle inexplicable test setlocale failure on Android,Linux. (Require success on other platforms) Skip setting the locale on Android, which is always C locale in C++, but for some reason std::locale::classic isn't implemented as a no-op. Bug: angleproject:2607 Test: angle_unittests Change-Id: I7c97cb56c01335db46f532fb8af3f9a4f2a30564 Reviewed-on: https://chromium-review.googlesource.com/1077789 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Geoff Lang 197d5294 2018-04-25T14:29:00 Wrap all preprocessor code in the angle namespace. BUG=836820 BUG=801364 Change-Id: I08b6a2f9f12b689e09df6efd916c313e71e8a051 Reviewed-on: https://chromium-review.googlesource.com/1028581 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org>
U-GOOGLE\courtneygo bab086a7 2018-03-30T16:08:42 Fix Tokenizer issue Updated Tokenizer running generate_parser.sh on Windows. Test: make Change-Id: I128a70a61907bb4ce3b0a8031667bda4197b6a2d Reviewed-on: https://chromium-review.googlesource.com/988802 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Yuly Novikov <ynovikov@chromium.org> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
Geoff Lang 98d0a2b1 2018-02-26T11:55:34 Use strtod instead of istringstream+locale for parsing floats. BUG=803034 Change-Id: I69ca7a86e1841e86c6a8cf6a0b7279a8e42b0012 Reviewed-on: https://chromium-review.googlesource.com/937964 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Nico Weber 41b072b6 2018-02-09T10:01:32 Prepare for -Wimplicit-fallthrough in ANGLE. Disable the warning for flex-generated output, which contains lots of intentional fallthrough. Fixes a bug where GL_SAMPLE_ALPHA_TO_ONE_EXT would fall through to GL_COVERAGE_MODULATION_CHROMIUM and hence behave like that. Fixes a bug in the D3D9 state management where invalidating DIRTY_BIT_POLYGON_OFFSET would also invalidate the stencil bits. One somewhat common incorrect pattern in ANGLE is nested switch statements that look like so: switch (a) { case a1: switch (b) { case b1: ... break; } case a2: ... } The assumption here seems to be that the breakk exits the outer case (here a1), while it in fact only exits the inner switch, so that we fall through to a2. In most places, I fixed this by adding an explicit `break` after the inner switch. This fixes a bug wher GL_PATH_JOIN_STYLE_CHROMIUM would fall through to GL_PATH_MITER_LIMIT_CHROMIUM in validation (but since the join style enum is always > 0, this happened to not have an effect in practice). This also fixes 87 bugs in GetLoadFunctionsMap() where invalid values would previously return an unrelated function map instead of the empty load function map. Bug: chromium:810767 Change-Id: Ib51388c73fbfc229160e2c10f8fb9364cc7c996c Reviewed-on: https://chromium-review.googlesource.com/911529 Commit-Queue: Nico Weber <thakis@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Luc Ferron e49f1e95 2018-01-24T14:47:55 Revert 3 files from previous merge I accidentally got the 3 files I was asked to revert part of the merge. This reverts them. Bug: angleproject:1695 Change-Id: I93a85776e890d0d35a5ff24973860006836c736f Reviewed-on: https://chromium-review.googlesource.com/884105 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Luc Ferron <lucferron@google.com>
Luc Ferron adcf0ae6 2018-01-24T08:27:37 Replace all NULL with nullptr Bug: angleproject:1695 Change-Id: Ide0591ffdad5815385a4d805b320a32533bcc03a Reviewed-on: https://chromium-review.googlesource.com/883681 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Luc Ferron <lucferron@google.com>
Jamie Madill acf2f3ad 2017-11-21T19:22:44 Apply Chromium style fixes. This addresses several minor code quality issues that are validated in Chromium, but not yet applied to ANGLE: * constructors and destructors must be defined out-of-line * auto is not allowed for simple pointer types * use override everywhere instead of virtual * virtual functions must also be defined out-of-line Slightly reduces binary size for me (~2k on Win, 150k on Linux). Bug: angleproject:1569 Change-Id: I073ca3365188caf5f29fb28d9eb207903c1843e6 Reviewed-on: https://chromium-review.googlesource.com/779959 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez d78e33a8 2017-10-30T12:33:52 preprocessor: Fix lineno overflow on line continuations BUG=chromium:774807 Change-Id: I4b3fbee31683f411810080572cfff0f8307b93bf Reviewed-on: https://chromium-review.googlesource.com/744183 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho a3d384ad 2017-10-06T16:12:50 Fix signed integer overflow in GLSL preprocessor left shift Signed integer overflow is undefined in C++, whereas unsigned integer overflow is not. Always cast left shift operand to unsigned to avoid UB. On common compilers, the behavior was already the same before this patch, so this patch is done mostly for the benefit of automated fuzz testing. BUG=chromium:743136 TEST=angle_unittests Change-Id: I7aab939036bb19a37f258cef4297b560da3cd9d5 Reviewed-on: https://chromium-review.googlesource.com/704659 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez dc0fa46a 2017-02-01T14:44:43 preprocessor: Check for line number overflow Also remove dead code in Tokenizer.l BUG=chromium:668842 Change-Id: Ice18313a64f0bb2242299993bfaa882a6578ad54 Reviewed-on: https://chromium-review.googlesource.com/435042 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez 168d5e80 2017-02-01T12:18:56 compiler: Regenerate parser with latest flex and bison Flex version is 2.6.4 Bison version is 3.0.4 BUG=chromium:668842 Change-Id: Ia05ae338c9b9e588534f8346ff5c59ed747c56bf Reviewed-on: https://chromium-review.googlesource.com/435553 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Frank Henigman aa7203ef 2017-05-03T23:32:29 Inherit privately from angle::NonCopyable. Make all inheritance from angle::NonCopyable private so the compiler complains about this (admittedly unlikely) code: class Foo: angle::NonCopyable { virtual ~Foo() { ... } }; angle::NonCopyable *p = new Foo; delete p; In the above code ~Foo() is not called, only ~NonCopyable(), because the latter is not virtual. Making it virtual would add overhead to all derived classes which don't already have a virtual method. Also tighten access in NonCopyable, because we can. BUG=angleproject:2026 Change-Id: Id0dc4d959cfb7bb82cf49382118129abb1d3a4f0 Reviewed-on: https://chromium-review.googlesource.com/495352 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Frank Henigman <fjhenigman@chromium.org>
Olli Etuaho 47c27e82 2017-01-17T15:29:35 Manage preprocessor Macro objects with shared pointers This ensures that pointers to Macros that are removed from the macro set stay valid. Pointers to undef'd macros may need to be referred to if reenabling the macros has been deferred. BUG=chromium:681324 TEST=angle_unittests Change-Id: Ibbbabbcbd6b0a84254cda717ae63712e6d404ebd Reviewed-on: https://chromium-review.googlesource.com/427948 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 77ba408a 2016-12-16T12:01:18 Unify Diagnostics interface Use the same kind of interface for reporting preprocessor errors as for reporting regular compiler errors, and make global errors like having too many uniforms also go through Diagnostics. Also don't create std::string objects unnecessarily. Includes cleanups of some dead code related to reporting errors. BUG=angleproject:1670 TEST=angle_unittests Change-Id: I3ee794d32ddeec1826bdf1b76b558f35259f82c0 Reviewed-on: https://chromium-review.googlesource.com/421527 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill f832c9dd 2016-12-12T17:38:48 Fix style in the preprocessor. Again using git cl format. BUG=angleproject:650 Change-Id: I8898d00bfc6a50db50bffd2cc30c3eda7c08c6c2 Reviewed-on: https://chromium-review.googlesource.com/419097 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho f1cf5e63 2016-11-22T17:36:49 Prevent stack overflow in macro expansion Add a configurable limit for how many nested MacroExpander objects can be created in the preprocessor, so that stack overflow can be prevented in case of malicious shaders. By default the limit is set to 1000. In unit tests the limit is set lower to make the test run faster. Includes refactoring of most of the preprocessor tests so that they use utility functions provided by the test class instead of repeating the same code for initializing the preprocessor. BUG=angleproject:1600 TEST=angle_unittests Change-Id: I23b5140d9f2dc52df96111650db63150f7238494 Reviewed-on: https://chromium-review.googlesource.com/413986 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 78b0c91d 2016-11-21T14:23:06 Fix infinite recursion in macro expansion BUG=angleproject:1600 TEST=angle_unittests Change-Id: I72bf81ec060f36255a0f13b132a4fd69b89672ff Reviewed-on: https://chromium-review.googlesource.com/412744 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho d1d1dff6 2016-11-03T14:56:14 Fix undefined modulus in ExpressionParser In constant folding of integer expressions this case is already being handled. BUG=angleproject:1599 Change-Id: Ifb3ea0279467f216e1c93909647b79fca24fcaf2 Reviewed-on: https://chromium-review.googlesource.com/406868 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill cfe7b2c4 2016-11-01T13:18:10 Add finite check to lexer float constants. The fuzzer was generating cases where floating point constants would someone return as valid when they were beyond max float. I was unable to reproduce this in a standalone test, but confirmed this check fixes the fuzzer error. BUG=660702 Change-Id: I9e6b883958013638ea509e38b30e812a9e74fbc1 Reviewed-on: https://chromium-review.googlesource.com/406268 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Corentin Wallez 449a8030 2016-10-26T08:05:54 MacroExpander: bump expansionCount before peeking for "(" BUG=658555 Change-Id: I578b8aff37a116fd7b2b387388311a27bb8a2809 Reviewed-on: https://chromium-review.googlesource.com/403848 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 7f9a55f7 2016-10-03T14:32:08 Fix integer math overflows in the preprocessor Evaluating integer expressions in the ESSL preprocessor may result in overflowing the signed integer range. Implement wrapping overflow for preprocessor expressions in a way that doesn't hit any undefined behavior. In the ESSL spec, preprocessor expressions are defined to have mostly the same semantics as in C++. Since C++ doesn't define what happens on signed integer overflow, we choose to make most of the operators wrap on overflow for backward compatibility and consistency with the rest of the ESSL spec. We reuse the existing wrapping overflow helpers that are used for constant folding. To be able to do this, the type used in the preprocessor expression parser is changed from 64-bit to 32-bit. Shifting negative numbers is implemented as a logical shift. This cannot be disallowed since dEQP requires shaders shifting negative numbers to pass compilation. Undefined bitwise shifts where the offset is greater than 31 will now result in a compile-time error. A couple of test cases are now covered by the preprocessor tests rather than full compilation tests. This isolates the tests better and they run faster. BUG=chromium:652223 TEST=angle_unittests Change-Id: I84be40d404c10ecd0846c5d477e626a94a2a8587 Reviewed-on: https://chromium-review.googlesource.com/392146 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Corentin Wallez 054f7ed0 2016-09-20T17:15:59 preprocessor: Miscellaneous cleanups - Use full header paths in includes - Use ASSERT instead of assert - Use angle::NonCopyable instead of PP_DISALLOW_COPY_AND_ASSIGN - Use range-for in a couple places - Remove pp_utils.h BUG=angleproject:1522 Change-Id: If107fef89e8465bca65cf664926d1051c5d1e232 Reviewed-on: https://chromium-review.googlesource.com/387212 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Corentin Wallez 2bd9c443 2016-09-20T16:39:18 preprocessor: add a limit to the number of token expanded BUG=angleproject:1522 BUG=chromium:648074 Change-Id: Ibf0858aaeb81933dd221ac82a49160169b48a495 Reviewed-on: https://chromium-review.googlesource.com/387211 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Corentin Wallez d2f195b5 2016-09-19T15:53:33 preprocessor: Fix use after free when #undef the macro being invoked BUG=chromium:648031 BUG=angleproject:1522 Change-Id: I825cea9e736a2c99133408249cfcd525431d31de Reviewed-on: https://chromium-review.googlesource.com/386853 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 93561c3a 2016-09-20T10:22:55 Regenerate the preprocessor with the latest versions of flex and bison. BUG=648063 Change-Id: Ia90d12c8cb4ae0a694227145267e78ca02dcc2b0 Reviewed-on: https://chromium-review.googlesource.com/387114 Commit-Queue: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Geoff Lang d4a07fbb 2016-09-20T10:24:23 Disallow bit-shifting when the left operand is negative. BUG=648063 Change-Id: I82d9fbdaf8791a396dd71eeb57d93967ba5d65bf Reviewed-on: https://chromium-review.googlesource.com/387115 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 461e3af8 2016-07-21T18:15:34 preprocessor: Fix negative shift with bad ids. Fix this by producing an error on undefined or negative shifts. BUG=629518 Change-Id: Idfca5ed3fc8e557f6178408f3426a5ef2ce7cf14 Reviewed-on: https://chromium-review.googlesource.com/362020 Reviewed-by: Antoine Labour <piman@chromium.org> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 1b2f1629 2016-03-04T15:06:51 Forbid defined operator generated by macro expansion After lengthy debate, the GLES working group recommended that this should be an error in WebGL, though old specs were not updated. Make ANGLE follow the WebGL spec and generate an error in this case. This is a partial revert of the patch which added support for defined operator generated by macro expansion. The preprocessor unit tests added by the reverted commit are kept, but their expectations are changed. This breaks some dEQP tests that are not in line with the WebGL spec. BUG=angleproject:1335 TEST=angle_unittests, WebGL conformance tests Change-Id: I7d8a1d42c61367197f2aed4ca4de9297cc48acfc Reviewed-on: https://chromium-review.googlesource.com/352471 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 4d675ca2 2016-03-07T14:48:49 Reserve "defined" as a macro name After lengthy debate, the GLES working group recommended that this should be an error in WebGL, though old specs were not updated. Make ANGLE follow the WebGL spec and generate an error in this case. This breaks some dEQP tests which are not in line with the WebGL spec. BUG=angleproject:1335 TEST=WebGL conformance tests Change-Id: I93fc397094419ecbf6a1b5179631b72064149bd0 Reviewed-on: https://chromium-review.googlesource.com/352470 Reviewed-by: Geoff Lang <geofflang@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez 946903d2 2016-04-18T17:30:07 Remove usage of auto_ptr in MacroExpander BUG=angleproject:1269 Change-Id: I1fafa102b065f6da1797e8790ec3ed498d9d8b45 Reviewed-on: https://chromium-review.googlesource.com/339379 Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 2f6ddf31 2015-09-22T16:10:07 Allow double underscore in macro names Double underscore is allowed according to GLSL ES 3.10, and based on Khronos discussions the intent is that this should also apply to older specs. The dEQP tests also check this, and WebGL tests that check the opposite were recently removed. The error is changed into a warning. BUG=angleproject:989 TEST=angle_unittests dEQP-GLES3.functional.shaders.preprocessor.* (2 tests start passing) dEQP-GLES2.functional.shaders.preprocessor.* (2 tests start passing) Change-Id: I582c01b4adc8fc416354351e02b776f2cc602408 Reviewed-on: https://chromium-review.googlesource.com/300965 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 247374cb 2015-09-09T15:07:24 Allow limited form of expressions in #line directives Reuse ExpressionParser that's also used for parsing preprocessor conditionals to parse line and file numbers in #line directives. According to recent Khronos discussions, the intent of the spec is that expressions in #line directives should be interpreted similarly to expressions in conditional directives, so reusing ExpressionParser is a natural way to implement this. This enables simple math operators operating on integers. There are a few unclear corner cases, but this approach is enough to support practical use cases and pass the dEQP tests. Valid line directives have one of the following forms: #line line-expression #line line-expression file-expression ExpressionParser is first run to parse the line-expression. In ambiguous cases the ExpressionParser consumes as much of the line as possible to form line-expression. Then, if end-of-line hasn't been reached, file-expression is parsed by running ExpressionParser again. As an example of an ambiguous case: #line 1 + 2 This could alternatively be interpreted to mean line-expression "1" and file-expression "+ 2" where + is the unary + operator, but ANGLE now interprets it to mean line-expression "1 + 2". Because of these ambiguous cases, a bison grammar that would parse multiple expressions on the same line couldn't be easily constructed, so this solution where ExpressionParser is run twice was chosen instead. The problematic corner cases are: - ExpressionParser uses 64-bit integers internally for evaluating the expression's value. It's possible to interpret the ESSL3 spec so that 32-bit integer wraparound behavior would be required also for #line directive expressions. - It's unclear whether the defined operator can be used in #line expressions. In this patch it is disabled. Hoping for further clarification from Khronos. - It's unclear how short-circuiting should affect the parsing of undefined identifiers in #line expressions. Now it's consistent with #if expressions (undefined identifiers are OK if they're short-circuited). dEQP expectations are updated for preprocessor tests, including ones not affected specifically by this change. BUG=angleproject:989 TEST=angle_unittests, dEQP-GLES3.functional.shaders.preprocessor.* (4 start passing), dEQP-GLES2.functional.shaders.preprocessor.* (4 start passing) Change-Id: I55c5bf75857da5de855cc600d3603ee19399f328 Reviewed-on: https://chromium-review.googlesource.com/300964 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 3187a38e 2015-09-09T12:00:12 Make preprocessor ExpressionParser only lex what it can parse This cleans up ExpressionParser so that the lexer only consumes one extra token in case the parser finishes. The parser will also finish with YYACCEPT once it has parsed a complete expression. This will make the preprocessor to generate a more informative unexpected token error instead of a syntax error if there are extra tokens after #if. This will also enable reusing ExpressionParser for parsing expressions in line directives. The format for a line directive that specifies both line and file numbers is as follows: #if line-expression file_expression ExpressionParser will need to be run twice for each line: first to parse line-expression and then to parse file-expression. For that reason, it is essential that ExpressionParser for line-expression stops before consuming more than one token of file-expression. BUG=angleproject:989 TEST=angle_unittests, dEQP-GLES3.functional.shaders.preprocessor.* Change-Id: I0bb92f733c18891eeddbc61e7c5bebdf1003559a Reviewed-on: https://chromium-review.googlesource.com/300962 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tryjob-Request: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 261f5379 2015-09-18T10:34:31 Support parsing defined operator generated by macro expansion dEQP tests enforce that the defined operator should be parsed even when it is generated as a result of macro expansion, even though this is undefined according to the C++ preprocessor spec. Implement support for this by putting the parsing for the defined operator inside MacroExpander. The operator gets processed right after it is generated by macro expansion. Parsing the defined operator is toggled with a boolean according to the context where MacroExpander is used. BUG=angleproject:989 TEST=angle_unittests, dEQP-GLES3.functional.shaders.preprocessor.* - 2 tests start passing: dEQP-GLES3.functional.shaders.preprocessor.conditional_inclusion.basic_2* Change-Id: I780e63bd4558253657d898685d62339017564a06 Reviewed-on: https://chromium-review.googlesource.com/300970 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho e6432c85 2015-09-08T14:21:38 Fix preprocessor macro replacement list location According to the dEQP tests, a macro replacement list generated by a function-like macro invocation should get its location from the closing parenthesis of the invocation. The tests check this by using __LINE__ in a macro with a multi-line invocation. It's not quite clear from the spec that the enforced behavior is expected as opposed to the replacement list getting its location from the macro name, but a minor correction to the preprocessor makes the dEQP tests pass. Newlines in the preprocessor unit tests are generated according to the source locations in the token list produced by the preprocessor, so the expectations of a few tests also need to be updated. BUG=angleproject:989 TEST=dEQP-GLES3.functional.shaders.preprocessor.predefined_macros.* (2 start passing with this change), angle_unittests Change-Id: I4cc9da09bd0985310a05ebf6def680916a46308a Reviewed-on: https://chromium-review.googlesource.com/297990 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Olli Etuaho 809ec546 2015-08-26T14:30:57 Don't evaluate short-circuited preprocessor expressions Resubmit with clang build issue fixed. The result of a short-circuited operation is now either 0 or 1. ESSL 3.00 spec section 3.4 mentions that the second operand in a logical && or || preprocessor operation is evaluated only if the first operand doesn't short-circuit the expression. The non-evaluated part of a preprocessor expression may also have undefined identifiers. Make the expression parser follow the spec by ignoring errors that are generated inside short-circuited expressions. This includes undefined identifiers and divide by zero. BUG=angleproject:347 TEST=dEQP-GLES3.functional.shaders.preprocessor.undefined_identifiers.* angle_unittests Change-Id: I4163f96ec46d40ac859ffb39d91b89490041e44d Reviewed-on: https://chromium-review.googlesource.com/297252 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 9a1b49f7 2015-09-08T14:32:26 Revert "Don't evaluate short-circuited preprocessor expressions" Build break on Clang: FAILED: /b/build/goma/gomacc ../../third_party/llvm-build/Release+Asserts/bin/clang++ -MMD -MF obj/third_party/angle/src/compiler/preprocessor/preprocessor.ExpressionParser.o.d -DV8_DEPRECATION_WARNINGS -DCLD_VERSION=2 -D__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORE=0 -DCHROMIUM_BUILD -DCR_CLANG_REVISION=245965-1 -DUSE_LIBJPEG_TURBO=1 -DENABLE_ONE_CLICK_SIGNIN -DENABLE_PRE_SYNC_BACKUP -DENABLE_WEBRTC=1 -DENABLE_MEDIA_ROUTER=1 -DUSE_PROPRIETARY_CODECS -DENABLE_PEPPER_CDMS -DENABLE_CONFIGURATION_POLICY -DENABLE_NOTIFICATIONS -DENABLE_HIDPI=1 -DSYSTEM_NATIVELY_SIGNALS_MEMORY_PRESSURE -DDONT_EMBED_BUILD_METADATA -DDCHECK_ALWAYS_ON=1 -DFIELDTRIAL_TESTING_ENABLED -DENABLE_TASK_MANAGER=1 -DENABLE_EXTENSIONS=1 -DENABLE_PDF=1 -DENABLE_PLUGIN_INSTALLATION=1 -DENABLE_PLUGINS=1 -DENABLE_SESSION_SERVICE=1 -DENABLE_THEMES=1 -DENABLE_AUTOFILL_DIALOG=1 -DENABLE_BACKGROUND=1 -DENABLE_GOOGLE_NOW=1 -DENABLE_PRINTING=1 -DENABLE_BASIC_PRINTING=1 -DENABLE_PRINT_PREVIEW=1 -DENABLE_SPELLCHECK=1 -DUSE_BROWSER_SPELLCHECKER=1 -DENABLE_CAPTIVE_PORTAL_DETECTION=1 -DENABLE_APP_LIST=1 -DENABLE_SETTINGS_APP=1 -DENABLE_SUPERVISED_USERS=1 -DENABLE_SERVICE_DISCOVERY=1 -DENABLE_WIFI_BOOTSTRAPPING=1 -DV8_USE_EXTERNAL_STARTUP_DATA -DFULL_SAFE_BROWSING -DSAFE_BROWSING_CSD -DSAFE_BROWSING_DB_LOCAL -DSAFE_BROWSING_SERVICE -DUSE_LIBPCI=1 -DUSE_OPENSSL=1 -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 -Igen -isysroot /Applications/Xcode5.1.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk -O2 -gdwarf-2 -fvisibility=hidden -Werror -Wnewline-eof -mmacosx-version-min=10.6 -arch x86_64 -Wendif-labels -Wno-unused-parameter -Wno-missing-field-initializers -Wno-selector-type-mismatch -Wpartial-availability -Wheader-hygiene -Wno-char-subscripts -Wno-unneeded-internal-declaration -Wno-covered-switch-default -Wstring-conversion -Wno-c++11-narrowing -Wno-deprecated-register -Wno-inconsistent-missing-override -Wno-shift-negative-value -Wno-unused-function -Wno-unused-variable -std=c++11 -fno-rtti -fno-exceptions -fvisibility-inlines-hidden -fno-threadsafe-statics -Xclang -load -Xclang /b/build/slave/GPU_Mac_Builder/build/src/third_party/llvm-build/Release+Asserts/lib/libFindBadConstructs.dylib -Xclang -add-plugin -Xclang find-bad-constructs -Xclang -plugin-arg-find-bad-constructs -Xclang check-templates -fcolor-diagnostics -fno-strict-aliasing -c ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp -o obj/third_party/angle/src/compiler/preprocessor/preprocessor.ExpressionParser.o ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1372:35: error: use of logical '||' with constant operand [-Werror,-Wconstant-logical-operand] (yyval) = (yyvsp[-3]) || 0; ^ ~ ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1372:35: note: use '|' for a bitwise operation (yyval) = (yyvsp[-3]) || 0; ^~ | ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: error: use of logical '&&' with constant operand [-Werror,-Wconstant-logical-operand] (yyval) = (yyvsp[-3]) && 0; ^ ~ ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: note: use '&' for a bitwise operation (yyval) = (yyvsp[-3]) && 0; ^~ & ../../third_party/angle/src/compiler/preprocessor/ExpressionParser.cpp:1406:35: note: remove constant to silence this warning (yyval) = (yyvsp[-3]) && 0; ~^~~~ BUG=angleproject:347 This reverts commit 6ffe613518482b966b913013c51221ce06ca7c33. Change-Id: I6d81666cca573f320bfb1164a6c794b6f75f7463 Reviewed-on: https://chromium-review.googlesource.com/298020 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho 6ffe6135 2015-08-26T14:30:57 Don't evaluate short-circuited preprocessor expressions ESSL 3.00 spec section 3.4 mentions that the second operand in a logical && or || preprocessor operation is evaluated only if the first operand doesn't short-circuit the expression. The non-evaluated part of a preprocessor expression may also have undefined identifiers. Make the expression parser follow the spec by ignoring errors that are generated inside short-circuited expressions. This includes undefined identifiers and divide by zero. BUG=angleproject:347 TEST=dEQP-GLES3.functional.shaders.preprocessor.undefined_identifiers.* angle_unittests Change-Id: Ieed02a71298af838f784a5d1197d4f4a9ba0e3c8 Reviewed-on: https://chromium-review.googlesource.com/295033 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Corentin Wallez e5a1f271 2015-08-21T02:58:25 Use override in all the places where it is possible This will avoid -Winconsistent-overrides in the future. Done using the -Wsuggest-override warning of GCC 5.1 BUG= Change-Id: I707a649dc368f5dd1e139fd144370abcac0b6263 Reviewed-on: https://chromium-review.googlesource.com/294920 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Olli Etuaho 26e355b8 2015-08-14T14:16:19 Add full support for line continuation in the preprocessor Re-landing earlier change with constant signedness fixed (was causing build issues on Linux). Line continuation in ESSL 3.00 needs to be processed before tokenization, since tokens can span the line continuation. On the other hand, ANGLE's tokenizer keeps track of line numbers, and whenever a line continuation appears the line number still needs to be incremented by one, just like on a regular newline. That's why line continuation is now implemented as follows: when the shader strings are concatenated in Input, they are also checked for line continuation. Whenever line continuation is encountered, the string is cut before that point. When the tokenizer asks for more input, the string starting from the character after line continuation is passed to it, and the line number is incremented from Input. This way the tokenizer can parse tokens that span multiple lines - it never sees the line continuation - but still keeps track of the line number correctly. Relevant spec is in ESSL 3.00 section 3.2 "Source strings". Support for line continuation also applies to ESSL 1.00. ESSL 3.00 spec section 1.5 says that line continuation support is mandated when an ESSL 1.00 shader is used with the OpenGL ES 3.0 API, and is optional when ESSL 1.00 is used with the OpenGL ES 2.0 API. TEST=dEQP-GLES3.functional.shaders.preprocessor.line_continuation.* (all pass), angle_unittests BUG=angleproject:1125 Change-Id: Ic086aacac53cd75bf93c0fda782416501d2f842b Reviewed-on: https://chromium-review.googlesource.com/294200 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Jamie Madill 3b040eb8 2015-08-17T16:51:33 Revert "Add full support for line continuation in the preprocessor" Warning in the Linux/Mac builders: In file included from ../../third_party/angle/src/tests/preprocessor_tests/input_test.cpp:7: In file included from ../../third_party/angle/src/tests/preprocessor_tests/PreprocessorTest.h:7: ../../testing/gtest/include/gtest/gtest.h:1392:16: error: comparison of integers of different signs: 'const int' and 'const unsigned long' [-Werror,-Wsign-compare] if (expected == actual) { ~~~~~~~~ ^ ~~~~~~ ../../testing/gtest/include/gtest/gtest.h:1422:12: note: in instantiation of function template specialization 'testing::internal::CmpHelperEQ<int, unsigned long>' requested here return CmpHelperEQ(expected_expression, actual_expression, expected, ^ ../../third_party/angle/src/tests/preprocessor_tests/input_test.cpp:171:5: note: in instantiation of function template specialization 'testing::internal::EqHelper<false>::Compare<int, unsigned long>' requested here EXPECT_EQ(3, input.read(buf, maxSize, &lineNo)); ^ BUG=angleproject:1125 This reverts commit c1157d1963170c7411eb6c32e2b2fbce02c5a170. Change-Id: Ic6fa286d190b006cccc5154d86e21ecc03175763 Reviewed-on: https://chromium-review.googlesource.com/294080 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Olli Etuaho c1157d19 2015-08-14T14:16:19 Add full support for line continuation in the preprocessor Line continuation in ESSL 3.00 needs to be processed before tokenization, since tokens can span the line continuation. On the other hand, ANGLE's tokenizer keeps track of line numbers, and whenever a line continuation appears the line number still needs to be incremented by one, just like on a regular newline. That's why line continuation is now implemented as follows: when the shader strings are concatenated in Input, they are also checked for line continuation. Whenever line continuation is encountered, the string is cut before that point. When the tokenizer asks for more input, the string starting from the character after line continuation is passed to it, and the line number is incremented from Input. This way the tokenizer can parse tokens that span multiple lines - it never sees the line continuation - but still keeps track of the line number correctly. Relevant spec is in ESSL 3.00 section 3.2 "Source strings". Support for line continuation also applies to ESSL 1.00. ESSL 3.00 spec section 1.5 says that line continuation support is mandated when an ESSL 1.00 shader is used with the OpenGL ES 3.0 API, and is optional when ESSL 1.00 is used with the OpenGL ES 2.0 API. TEST=dEQP-GLES3.functional.shaders.preprocessor.line_continuation.* (all pass), angle_unittests BUG=angleproject:1125 Change-Id: I1c1de49602e7cd755d6072c3c0aa5524cd0313b4 Reviewed-on: https://chromium-review.googlesource.com/293721 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Nico Weber ec17d54a 2015-08-13T12:19:28 Fix angle miscompiling shaders on x86_64 Android. BUG=487341 Change-Id: I792e0c9419566facb0bec0ad93f3646294e5a2a7 Reviewed-on: https://chromium-review.googlesource.com/293500 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Nico Weber <thakis@chromium.org> Reviewed-by: Nico Weber <thakis@chromium.org>
Olli Etuaho 6cb4c7f0 2015-08-13T11:27:17 Set __VERSION__ macro when the #version directive is parsed __VERSION__ macro needs to be set to 300 when #version 300 es is on the first line of the shader, since section 3.4 of ESSL 3.00.4 spec mentions that the value of __VERSION__ should match the shading language being parsed. The value from parsing the version directive replaces the default value 100. BUG=angleproject:524 TEST=dEQP-GLES3.functional.shaders.preprocessor.predefined_macros.* (4 tests start passing, 2 still fail) dEQP-GLES3.functional.shaders.preprocessor.conditionals.* (2 tests start passing) dEQP-GLES2.functional.shaders.preprocessor.predefined_macros.* (no regression) Change-Id: I15bfdeb73d1e343d131ded56b1fd52ca5ef32408 Reviewed-on: https://chromium-review.googlesource.com/293440 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com>
Olli Etuaho 391befef 2015-08-12T16:30:38 Revert "Add pragma errors for malformed pragmas." Since this commit was made, dEQP tests were fixed to check that unrecognized pragma tokens only generate warnings, not errors. This applies to both ESSL1.00 and ESSL3.00, which specify this behavior in section 3.4 Preprocessor. BUG=angleproject:989 TEST=dEQP-GLES2.functional.shaders.preprocessor.pragmas.* This reverts commit d3c29f57aaeb451b149bbb9fd17b3f1f99101c52. Change-Id: Ie4e0ec061fa3164d6f3872ac0016a063056ed110 Reviewed-on: https://chromium-review.googlesource.com/293181 Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang b3a6a8f3 2015-06-23T16:10:14 Error when encountering non-preprocessor tokens before #extension in ESSL3. BUG=angleproject:1047 Change-Id: I4a548270f651e35b2c8d1ab5d0f46185230c5f74 Reviewed-on: https://chromium-review.googlesource.com/281216 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Olli Etuaho c378cd8a 2015-05-25T15:21:44 Check that #version 300 es directive is on the first line ESSL3.00 and 3.10 specs don't allow even newlines before the version directive. BUG=angleproject:1009 TEST=WebGL 2 conformance tests, angle_unittests Change-Id: Id7967829077e35e03572c724e0eafffbed0c975b Reviewed-on: https://chromium-review.googlesource.com/272719 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Geoff Lang 06e24a7e 2015-04-27T14:48:59 Track if a non-preprocessor token has been seen and validate #extension with it. Reland: Only report a warning instead of an error. BUG=angleproject:989 BUG=483252 Change-Id: Ife3e7759cdef6bc0f41cae3c58c307682b608279 Reviewed-on: https://chromium-review.googlesource.com/269404 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 4b6bfe10 2015-05-05T20:10:20 Revert "Track if a non-preprocessor token has been seen and validate #extension with it." Causing failures in the GLES2 CTS "build", related to extensions. BUG=483252 BUG=angleproject:989 This reverts commit bbdb9e2259c38454be097ce01505db83db3ad7a8. Change-Id: I3e1ad989af645194c8ee9b9847b2131e289d09e1 Reviewed-on: https://chromium-review.googlesource.com/269403 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Geoff Lang bbdb9e22 2015-04-27T14:48:59 Track if a non-preprocessor token has been seen and validate #extension with it. Reland: Only report a warning instead of an error. BUG=angleproject:989 BUG=483252 Change-Id: Ibf9adbf423cd9dee20ec45b8d2ea42bcfd9311be Reviewed-on: https://chromium-review.googlesource.com/269205 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Scott Graham a897542f 2015-05-01T11:09:12 vs2015: disable warning in generated code, fix another Macro redefinition is for INT8_MIN, etc. which are generated by flex. VS doesn't define __STDC_VERSION__ as >= C99 because it's still only partial support in VS2015. Fix a float->int conversion narrowing warning. Change-Id: I5232eb23426eaf584218137c068e14d74119a1ef Reviewed-on: https://chromium-review.googlesource.com/268821 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Scott Graham <scottmg@chromium.org>
Geoff Lang 4c8cae60 2015-05-01T16:46:16 Revert "Don't mark all macros with double underscores as reserved." Fails a WebGL CTS test. BUG=angleproject:989 This reverts commit 942e36254a1e3537371c39f3f23d1ce12f4c87e8. Change-Id: I9f833366d5b69535ef74e358ac21efaccb1f1a3d Reviewed-on: https://chromium-review.googlesource.com/268751 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 942e3625 2015-04-30T11:00:01 Don't mark all macros with double underscores as reserved. Only __FILE__, __LINE__, __VERSION__ and GL_ES are reserved but it is still not recommended to use a name with double underscores because it may be used by the "underlying software layers". Updated the tests to reflect that it is OK to define macros with double underscores but it is not valid to make assumptions about their values. Fixes: dEQP-GLES2.functional.shaders.preprocessor.basic.identifier_with_double_underscore_vertex dEQP-GLES2.functional.shaders.preprocessor.basic.identifier_with_double_underscore_fragment BUG=angleproject:898 Change-Id: I77054d04c9935eedcdbb7304dc0c3b60b53994f9 Reviewed-on: https://chromium-review.googlesource.com/268434 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 2dc8bf8b 2015-04-30T15:56:52 translator: Fix C++11-deprecated register usage. Define 'register' as an empty string if we're in a modern version of C++. BUG=255186 BUG=angleproject:463 Change-Id: Ied044fb87a9b05c91cb419c54295c39f0f0ab776 Reviewed-on: https://chromium-review.googlesource.com/268512 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill b96687df 2015-04-30T15:56:51 translator: Regenerate with Bison 3.0.4. BUG=angleproject:463 Change-Id: If89a29de8fb006e8e3b0483ac5df21c8833ce974 Reviewed-on: https://chromium-review.googlesource.com/268511 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 9624e058 2015-05-01T14:04:24 Revert "Track if a non-preprocessor token has been seen and validate #extension with it." Breaks some WebGL applications, holding off until a decision is made. BUG=483252 BUG=angleproject:989 This reverts commit fa55bf1ed6a26341c57f45b3a3da8feda0b6c18d. Change-Id: Iebef439095a95741c8502716a4ce90c4785561eb Reviewed-on: https://chromium-review.googlesource.com/268742 Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang fa55bf1e 2015-04-27T14:48:59 Track if a non-preprocessor token has been seen and validate #extension with it. Fixes: dEQP-GLES2.functional.shaders.preprocessor.extensions.after_non_preprocessing_tokens_vertex dEQP-GLES2.functional.shaders.preprocessor.extensions.after_non_preprocessing_tokens_fragment BUG=angleproject:989 Change-Id: Ie0aba80b2fde0160e83fc95f545b62954af2e5fc Reviewed-on: https://chromium-review.googlesource.com/267398 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 26be18da 2015-04-27T14:05:57 Validate that all preprocessor function arguments are unique. Fixes: dEQP-GLES2.functional.shaders.preprocessor.invalid_function_definitions.unique_param_name_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_function_definitions.unique_param_name_fragment BUG=angleproject:989 Change-Id: I32198f1c9036c371b46e7ad2986a44e42fd38e20 Reviewed-on: https://chromium-review.googlesource.com/267396 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang 95a423d0 2015-04-28T11:09:45 Unexpected tokens after conditionals should be an error instead of a warning. Fixes: dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_if_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_if_fragment dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_else_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_else_fragment dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_endif_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_endif_fragment dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_ifdef_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_ifdef_fragment dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_ifndef_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_conditionals.tokens_after_ifndef_fragment BUG=angleproject:989 Change-Id: I6511f7082c98206fb623775d81329b6bc7673c1a Reviewed-on: https://chromium-review.googlesource.com/267638 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang d3c29f57 2015-04-28T11:23:02 Add pragma errors for malformed pragmas. Instead of always warning on invalid pragmas, only warn when the pragma type is not recognized and error when the syntax is invalid. Fixes: dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_debug_vertex dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_debug_fragment dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_token_vertex dEQP-GLES2.functional.shaders.preprocessor.pragmas.invalid_pragma_invalid_token_fragment BUG=angleproject:989 Change-Id: Ibd584dc08a2436e163dfc52eeffdf2dac8a22cb8 Reviewed-on: https://chromium-review.googlesource.com/267639 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Geoff Lang b819d25d 2015-04-27T14:16:34 Validate that there are no tokens following #undef on the same line. Fixes: dEQP-GLES2.functional.shaders.preprocessor.definitions.undefine_object_invalid_syntax_vertex dEQP-GLES2.functional.shaders.preprocessor.definitions.undefine_object_invalid_syntax_fragment dEQP-GLES2.functional.shaders.preprocessor.invalid_definitions.undef_non_identifier_2_vertex dEQP-GLES2.functional.shaders.preprocessor.invalid_definitions.undef_non_identifier_2_fragment BUG=angleproject:989 Change-Id: I279a38aaae8010017ef6e3f1aa139ae03f374680 Reviewed-on: https://chromium-review.googlesource.com/267397 Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Minmin Gong 794e0009 2015-04-07T18:31:54 Fix and enable warning C4244 (Conversion from 'type1' to 'type2', possible loss of data) Change-Id: Id0e06d7d6600344d858f00dabc219d79289bbc82 Reviewed-on: https://chromium-review.googlesource.com/265020 Tested-by: Minmin Gong <mgong@microsoft.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill b3584fb4 2015-04-09T17:34:21 Revert "Fix and enable warning C4244 (Conversion from 'type1' to 'type2', possible loss of data)" Causing a build failure on Mac/Clang: ./Tokenizer.cpp:551:7: error: extra tokens at end of #else directive [-Werror,-Wextra-tokens] #else if defined(_MSC_VER) http://build.chromium.org/p/chromium.gpu.fyi/builders/GPU%20Mac%20Builder/builds/29136 This reverts commit 3b26e231d99154814eb428f75a67bbe7a21adadc. Change-Id: I2d11ddcc18130d908fd2ec3d6f5ab890cfccd5e7 Reviewed-on: https://chromium-review.googlesource.com/264983 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Minmin Gong 3b26e231 2015-04-07T18:31:54 Fix and enable warning C4244 (Conversion from 'type1' to 'type2', possible loss of data) Change-Id: I73d9a2b9ad16f032be974b9c819de0dc1247c2ea Reviewed-on: https://chromium-review.googlesource.com/264533 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Austin Kinross c8ef69d2 2015-03-18T16:43:22 Fix C4702 issues (unreachable code) in ANGLE, excluding <xtree> Change-Id: Ia7603139af266fd7b14efc8c3465225738456e67 Reviewed-on: https://chromium-review.googlesource.com/261038 Tested-by: Austin Kinross <aukinros@microsoft.com> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 185de884 2014-12-22T15:17:52 Update ANGLE's translator to Bison 3. BUG=angle:462 Change-Id: I2c1c18027dee1c3b4efb87374caaadbf58367841 Reviewed-on: https://chromium-review.googlesource.com/236930 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Kenneth Russell <kbr@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org>
Geoff Lang 0a73dd85 2014-11-19T16:18:08 Fix include guards. BUG=angle:733 Change-Id: I08b2c11c4831f1161c178c1842b10e807185aced Reviewed-on: https://chromium-review.googlesource.com/230831 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Zhenyao Mo b5e17750 2014-10-22T10:57:10 Get rid of use of "static const std::string". BUG=angle:807 TEST=angle_unittests Change-Id: Ifa4d713deeb25d52a7aafc362a7e4630024fd511 Reviewed-on: https://chromium-review.googlesource.com/225004 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Zhenyao Mo 94ac7b78 2014-10-15T18:22:08 Invariant related processing. * Fix a bug in PreProcessor for STDGL pragma. * Record all invariant settings and set them in ShaderVariable. * Write #pragma STDGL invariant(all) in GL BUG=angle:776 TEST=https://www.khronos.org/registry/webgl/sdk/tests/conformance/glsl/misc/shaders-with-invariance.html Change-Id: Ie28b75480deed79f0c9f26e3b98f1778d1290182 Reviewed-on: https://chromium-review.googlesource.com/223610 Tested-by: Zhenyao Mo <zmo@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>
Zhenyao Mo d526f989 2014-05-13T14:51:19 Fix code style violation in compiler/preprocessor BUG=angle:650 TEST=no behavior change Change-Id: Ib52f15f6471fc7897b66d11baee11216cf08158a Reviewed-on: https://chromium-review.googlesource.com/199591 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Zhenyao Mo <zmo@chromium.org> Tested-by: Zhenyao Mo <zmo@chromium.org>
Jamie Madill 5508f39d 2014-02-20T13:31:36 Fix breaking the build with missing GetGlobalMaxTokenSize. Because the preprocessor is used independently from the compiler, we need a way to track max token size when we don't have access to the parse context with the current spec. BUG=angle:550 Change-Id: Idf5035ec2c001ee75f264151ab3c4e92f3cd44d7 Reviewed-on: https://chromium-review.googlesource.com/187140 Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 88f6e946 2014-02-19T10:27:53 Proper support for token max size in WebGL+ES3. WebGL specifies a maximum token size of 256 characters, while ES3 specifies 1024 characters. We can determine the proper max size to support from the spec. BUG=angle:550 Change-Id: I6aeabe8af3b6184a27b456248ce2f84f361b76e4 Reviewed-on: https://chromium-review.googlesource.com/186973 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill c9f140d8 2014-02-18T15:27:21 Add preprocess bison files to the gyp files. We had accidentally left out the y and l files from our generation scripts, causing us to miss several instances of updated enum names. BUG=angle:550 Change-Id: I8790742fbaab5435e4c0db4f61c3e8194a231550 Reviewed-on: https://chromium-review.googlesource.com/186972 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill a738f085 2013-11-01T17:45:04 Fix build on QNX. InfoSink.h needs stdlib.h for abs(int) and free() in the global namespace. ExpressionParser needs malloc.h, because bison needs malloc and free in the global namespace, but "#include <cassert>" will put it only in the std:: namespace on QNX. BUG=500 R=geofflang@chromium.org, jmadill@chromium.org, shannonwoods@chromium.org, zmo@chromium.org Review URL: https://codereview.appspot.com/19330044 Change-Id: Ifa30a8ba5eced1156123416d4a24b490620721af Reviewed-on: https://chromium-review.googlesource.com/178993 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Shannon Woods <shannonwoods@chromium.org>
Jamie Madill d7f2135f 2013-10-30T17:53:15 Fix build on QNX. InfoSink.h needs stdlib.h for abs(int) and free() in the global namespace. ExpressionParser needs malloc.h, because bison needs malloc and free in the global namespace, but "#include <cassert>" will put it only in the std:: namespace on QNX. BUG=500 R=geofflang@chromium.org, shannonwoods@chromium.org Review URL: https://codereview.appspot.com/19330044 Conflicts: src/compiler/translator/InfoSink.h Change-Id: Ie480d5c293d099f21dafc8c1e7997c0b4cda7207 Reviewed-on: https://chromium-review.googlesource.com/178998 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Tested-by: Shannon Woods <shannonwoods@chromium.org>
Shannon Woods 7f2d7945 2013-11-19T15:07:58 Manual merge of Ehsan Akhgari's patch to rename Diagnostics enums to avoid collision with Windows.h (See https://chromium-review.googlesource.com/#/c/177181/3) Change-Id: I2978d06ec96789b3ee1696b65a84c2a9f31f7ba4
Geoff Lang 7c697201 2013-10-07T17:18:14 Deleted manually maintained visual studio projects and replaced them with gyp generated ones.
Zhenyao Mo f1d723c6 2013-09-23T14:57:07 Clamp numeric overflow rather than failing with an error BUG=249086 ANGLEBUG=468 TEST= R=alokp@chromium.org, kbr@chromium.org Review URL: https://codereview.appspot.com/13195043