src/tests/preprocessor_tests/if_test.cpp


Log

Author Commit Date CI Message
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>
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>
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>
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>
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 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>
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 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 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 2728f992 2015-08-31T16:24:10 Make unittest #includes start from src This is will help avoid adding many include directories for the GN build. BUG=angleproject:929 Change-Id: If8f7e98526df3560b8e410ec86271a2da0c6889d Reviewed-on: https://chromium-review.googlesource.com/296480 Reviewed-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Corentin Wallez <cwallez@chromium.org>
Jamie Madill 559a2e8c 2015-03-16T17:25:51 Move the ANGLE tests project to src/ *re-re-land with fix for Chrome's angle tests* BUG=angleproject:945 Change-Id: I3c64e2edc776c299791440f65f22450855eb6dfa Reviewed-on: https://chromium-review.googlesource.com/260448 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 96e3f556 2015-03-16T21:24:20 Revert "Move the ANGLE tests project to src/" Still causing build issues on Chrome. This reverts commit 64a3b2a92fe3bbd28972638e6759fae0b98d81b9. Change-Id: I8d40fe3dfd0a877343357153a02b8ef66d571c64 Reviewed-on: https://chromium-review.googlesource.com/260425 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 64a3b2a9 2015-03-16T11:00:20 Move the ANGLE tests project to src/ *re-land with fix for Chromium build* BUG=angleproject:945 Change-Id: I82bff1760e681987fb26e479734aa62fb845898a Reviewed-on: https://chromium-review.googlesource.com/260362 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org>
Jamie Madill 5491fe66 2015-03-16T17:56:18 Revert "Move the ANGLE tests project to src/" Causing build break in Chromium. This reverts commit 71c2d85c4af2f6cb213d4f3e15f0ae16b63790f3. Change-Id: Iedf001c1f4c60a759f69009610fbce978d193d17 Reviewed-on: https://chromium-review.googlesource.com/260370 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
Jamie Madill 71c2d85c 2015-03-16T10:47:04 Move the ANGLE tests project to src/ BUG=angleproject:945 Change-Id: I2eb44ac43f65b916ddd838d39e6aae62580d7fa0 Reviewed-on: https://chromium-review.googlesource.com/258903 Tested-by: Jamie Madill <jmadill@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org>