Commit Graph

31 Commits

Author SHA1 Message Date
John Zupin
eeff9af1e6
fix strncpy bound error (#4331) 2021-06-29 10:07:13 -04:00
dan sinclair
ef678672fb
Remove source/message.h (#1838)
The code in source/message was only used in a single set of tests to
format the output results. This CL changes the test to verify the
message instead of all the error values and removes the source/message
code.
2018-08-14 15:41:21 -04:00
dan sinclair
eda2cfbe12
Cleanup includes. (#1795)
This Cl cleans up the include paths to be relative to the top level
directory. Various include-what-you-use fixes have been added.
2018-08-03 15:06:09 -04:00
dan sinclair
3dad1cda11
Change libspirv to spvtools namespace (#1678)
This CL changes all of the libspirv namespace code to spvtools to match
the rest of the code base.
2018-07-07 09:38:00 -04:00
dan sinclair
51091045fe
Produce better error diagnostics in the CFG validation. (#1660)
Produce better error diagnostics in the CFG validation.

This CL fixes up several issues with the diagnostic error line output
in the CFG validation code. For the cases where we can determine a
better line it has been output. For other cases, we removed the
diagnostic line and the error line number from the results.

Fixes #1657
2018-07-03 15:06:54 -04:00
dan sinclair
f80696eaf6
[val] Add extra context to error messages. (#1600)
[val] Add extra context to error messages.

This CL extends the error messages produced by the validator to output the
disassembly of the errored line.

The validation_id messages have also been updated to print the line number of
the error instead of the word number. Note, the error number is from the start
of the SPIR-V, it does not include any headers printed in the disassembled code.

Fixes #670, #1581
2018-06-19 16:02:44 -04:00
David Neto
c2999273d9 Move SetContextMessageConsumer into libspirv namespace
Avoid polluting the global namespace.
2017-11-23 13:56:12 -05:00
David Neto
169266e9b8 DiagnosticStream move ctor moves output duties to new object
- Take over contents of the expiring message stream
- Prevent the expiring object from emitting anything during destruction
2017-10-03 11:23:54 -04:00
David Neto
c3caa546a0 spirv-val prints warnings
Warnings and info messages go to stdout.
Errors still go to stderr.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/568
2017-03-17 12:48:51 -04:00
Lei Zhang
620f05e679 Publish the C++ interface. 2016-09-21 14:41:47 -04:00
Lei Zhang
6849a3cefd Use C style names for MessageLevel. 2016-09-21 12:44:37 -04:00
Lei Zhang
80eb0793c9 Change to use enum instead of enum class for MessageLevel.
This allows us to create C interface with MessageLevel later.
2016-09-21 11:30:41 -04:00
Lei Zhang
3590279a73 Set the default source name as "input". 2016-09-19 10:20:22 -04:00
Lei Zhang
755f97f534 Add a callback mechanism for communicating messages to callers.
Every time an event happens in the library that the user should be
aware of, the callback will be invoked.

The existing diagnostic mechanism is hijacked internally by a
callback that creates an diagnostic object each time an event
happens.
2016-09-15 12:35:48 -04:00
David Neto
9fc8658ef3 Relicense SPIRV-Tools under Apache 2.0
Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/383

Finalize v2016.4
2016-09-02 10:00:29 -04:00
Lei Zhang
6f13c73229 Remove some unused macros and functions. 2016-08-24 09:34:06 -04:00
Umar Arshad
90a4252aae Split validate_types file into multiple classes
Creates separate files for the ValidationState, Function and
BasicBlock classes.
2016-06-08 14:40:33 -04:00
Jamie Madill
34cb0035fd Fix several warnings exposed in MSVS 2015.
diagnostic.cpp:
- unreachable code

operand.cpp
- conversion between int and uint32_t
- unreachable code

hex_float.h:
- conversion from 'const int' to 'unsigned int'
- unreachable code

validate_id.cpp
- forcing value to bool 'true' or 'false'

validate_types.cpp:
- forcing value to bool 'true' or 'false'
2016-04-29 18:02:01 -04:00
Eric Engestrom
eb6ae976c6 Remove unnecessary null pointer checks
Fixes #110
2016-02-18 23:43:25 +00:00
David Neto
5a70335bf1 Rearrange headers
Now we have public headers arranged as follows:
$SPIRV_TOOLS_ROOT/include/spirv-tools/libspirv.h
$SPIRV_TOOLS_ROOT/include/spirv/spirv.h
$SPIRV_TOOLS_ROOT/include/spirv/GLSL.std.450.h
$SPIRV_TOOLS_ROOT/include/spirv/OpenCL.std.h

A project should use -I$SPIRV_TOOLS_ROOT/include
and then #include "spirv-tools/libspirv.h"

The headers from the SPIR-V Registry can be accessed as "spirv/spirv."
for example.

The install target should also install the headers from the SPIR-V
Registry.  The libspirv.h header is broken otherwise.

The SPIRV-Tools library depends on the headers from the SPIR-V Registry.

The util/bitutils.h and util/hex_float.h are pulled into the internal
source tree.  Those are not part of the public API to SPIRV-Tools.
2016-02-17 14:49:44 -05:00
Umar Arshad
c741385976 Function and block layout checks. very basic CFG.
This adds function and block layout checks to the validator. Very
basic CFG code has been added to make sure labels and branches
are correctly ordered.

Also:
* MemoryModel and Variable instruction checks/tests
* Use spvCheckReturn instead of CHECK_RESULT
* Fix invalid SSA tests
* Created libspirv::spvResultToString in diagnostic.h
* Documented various functions and classes
* Fixed error messages
* Fixed using declaration for FunctionDecl enum class
2016-01-13 10:06:58 -05:00
Dejan Mircevski
b6fe02fc39 Extend copyright to 2016. 2016-01-07 13:44:22 -05:00
David Neto
01656363a7 Put DiagnosticStream and clr exports in libspirv namespace
Each exported functions either has an "spv" prefix, or is inthe libspirv
namespace.

Fixes https://github.com/KhronosGroup/SPIRV-Tools/issues/18
2015-11-20 10:46:42 -05:00
Lei Zhang
923f6c13fc Use quotation for libspirv.h and sort headers. 2015-11-12 09:43:01 -05:00
David Neto
bae8851111 DiagnosticStream keeps a copy of the position.
Don't store the pointer, as the underlying storage
could disappear.  This a bit more flexible and robust.
2015-11-10 15:57:04 -05:00
Lei Zhang
1a0334edee Run clang-format to enforce Google style globally.
Note that we are more strict than Google style for one aspect:
pointer/reference indicators are adjacent to their types, not
their variables.

find . -name "*.h" -exec clang-format -i {} \;
find . -name "*.cpp" -exec clang-format -i {} \;
2015-11-10 15:56:47 -05:00
David Neto
51013d15ee SPV_FAILED_MATCH error mutes DiagnosticStream.
The DiagnosticStream will not emit the accumulated message
text if the error is SPV_FAILED_MATCH.

Change various interfaces to accept the intended error
code instead of a boolean "is_optional".  This allows
us to avoid repeating the following type of logic deep
inside helper methods:

  if (is_optional) return SPV_FAILED_MATCH;
  return diagnostic() << " message text ";
2015-10-26 12:55:33 -04:00
Andrew Woloszyn
71fc05587b Refactored dynamic and static state out of text processing.
This reduces the number of arguments required to be passed
to every single function. This is in preparation for adding
id tracking.
2015-10-26 12:55:33 -04:00
Lei Zhang
4005670363 Limit the use of spvCheck and spvCheckReturn to validator.
spvCheck is indeed just an if-statement. Defining such a macro
doesn't help much.
2015-10-26 12:55:33 -04:00
David Neto
c978643748 Print diagnostics at the beginning of input.
A spv_diagnostic_t value knows if the source is textual rather
than binary.
2015-10-26 12:52:01 -04:00
Kenneth Benzie (Benie)
83e5a29b06 Code drop of the Codeplay spirv-tools source.
This commit contains the source for the SPIRV static library, spirv-as,
spirv-dis, and spirv-val tools.
2015-05-22 18:26:19 +01:00