[all-commits] [llvm/llvm-project] 19a0a5: [HLSL] Add utility to convert environment to stage
Chris B via All-commits
all-commits at lists.llvm.org
Wed Oct 12 14:32:07 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 19a0a56749110dc92b39f583e46779ff23aceeba
https://github.com/llvm/llvm-project/commit/19a0a56749110dc92b39f583e46779ff23aceeba
Author: Chris Bieneman <chris.bieneman at me.com>
Date: 2022-10-12 (Wed, 12 Oct 2022)
Changed paths:
M clang/include/clang/Basic/HLSLRuntime.h
M clang/include/clang/Basic/LangOptions.h
M clang/lib/Frontend/InitPreprocessor.cpp
M clang/lib/Sema/SemaDecl.cpp
M clang/lib/Sema/SemaDeclAttr.cpp
M llvm/include/llvm/ADT/Triple.h
Log Message:
-----------
[HLSL] Add utility to convert environment to stage
We had a bunch of places in the code where we were translating triple
environment enum cases to shader stage enum cases. The order of these
enums needs to be kept in sync for the translation to be simple, but we
were not properly handling out-of-bounds cases.
In normal compilation out-of-bounds cases shouldn't be possible because
the driver errors if you don't have a valid shader environment set, but
in clang tooling that error doesn't get treated as fatal and parsing
continues. This can result in crashes in clang tooling for out-of-range
shader stages.
To address this, this patch adds a constexpr method to handle the
conversion which handles out-of-range values by converting them to
`Invalid`.
Since this new method is a constexpr, the tests for this are a group of
static_asserts in the implementation file that verifies the correct
conversion for each valid enum case and validates that other cases are
converted to `Invalid`.
Reviewed By: bogner
Differential Revision: https://reviews.llvm.org/D135595
More information about the All-commits
mailing list