[clang] [HLSL] Support vector swizzles on scalars (PR #67700)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 23 11:24:25 PDT 2023


================
@@ -930,7 +930,11 @@ NumericLiteralParser::NumericLiteralParser(StringRef TokSpelling,
   // and FP constants (specifically, the 'pp-number' regex), and assumes that
   // the byte at "*end" is both valid and not part of the regex.  Because of
   // this, it doesn't have to check for 'overscan' in various places.
-  if (isPreprocessingNumberBody(*ThisTokEnd)) {
+  // Note: For HLSL, the end token is allowed to be '.' which would be in the
+  // 'pp-number' regex. This is required to support vector swizzles on numeric
+  // constants (i.e. 1.xx or 1.5f.rrr).
+  if (isPreprocessingNumberBody(*ThisTokEnd) &&
+      !(LangOpts.HLSL && *ThisTokEnd == '.')) {
----------------
llvm-beanz wrote:

This used to be an `assert` in LLVM 3.7, but it changed two years ago in 5a6dac66db67225e2443f4e61dfe9d2f96780611. It looks like `clangd` can hit this path so the `if` is needed rather than just `assert`.

https://github.com/llvm/llvm-project/pull/67700


More information about the cfe-commits mailing list