[PATCH] D124751: [HLSL] Support -E option for HLSL.

Bruno Cardoso Lopes via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 26 17:52:30 PDT 2022


bruno added a comment.

Hi, nice to see this getting in. Comments inline!



================
Comment at: clang/lib/Sema/SemaDecl.cpp:11720
+    if (!FD->hasAttr<HLSLNumThreadsAttr>()) {
+      Diag(FD->getLocation(), diag::err_hlsl_missing_numthreads) << "Compute";
+      FD->setInvalidDecl();
----------------
You can use `getEnvironmentTypeName` to get the name here.


================
Comment at: clang/lib/Sema/SemaDecl.cpp:11721
+      Diag(FD->getLocation(), diag::err_hlsl_missing_numthreads) << "Compute";
+      FD->setInvalidDecl();
+    }
----------------
Since this is both checking and invalidating a decl, perhaps it should return a bool (maybe some asserts in the default case?) and be renamed `CheckAndInvalidateHLSLEntryPoint`?


================
Comment at: clang/test/SemaHLSL/entry.hlsl:2
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -Efoo -DWITH_NUM_THREADS -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -Efoo  -o - %s  -verify
+
----------------
Can you also add a check that rejects `-Efoo` with an error message when the language is not `hlsl`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124751/new/

https://reviews.llvm.org/D124751



More information about the cfe-commits mailing list