summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-modifier.cpp
diff options
context:
space:
mode:
authorSai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com>2024-08-27 21:13:00 -0400
committerGitHub <noreply@github.com>2024-08-27 18:13:00 -0700
commit6bb32aa976494466bd6303f8ae6e348b297edb44 (patch)
tree54765fd5168e1d6590f403c6df04b30404ee6346 /source/slang/slang-check-modifier.cpp
parenta9882c648c58e6f2821df11c7ee6ac77d9f09473 (diff)
Adds a warning for using `[PreferRecompute]` on methods that may contain side effects (#4707)
* Adds a warning for using prefer-recompute on methods that contain side effects * Rename `SideEffects` -> `SideEffectBehavior` --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/slang/slang-check-modifier.cpp')
-rw-r--r--source/slang/slang-check-modifier.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index 483ff0e18..705d0bb3b 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -842,6 +842,16 @@ namespace Slang
else if (auto primalOfAttr = as<PrimalSubstituteOfAttribute>(attr))
primalOfAttr->funcExpr = attr->args[0];
}
+ else if (auto preferRecomputeAttr = as<PreferRecomputeAttribute>(attr))
+ {
+ SLANG_ASSERT(attr->args.getCount() == 1);
+ SLANG_ASSERT(as<Decl>(attrTarget));
+
+ auto val = checkConstantIntVal(attr->args[0]);
+ if (!val) return false;
+
+ preferRecomputeAttr->sideEffectBehavior = (PreferRecomputeAttribute::SideEffectBehavior) val->getValue();
+ }
else if (auto comInterfaceAttr = as<ComInterfaceAttribute>(attr))
{
SLANG_ASSERT(attr->args.getCount() == 1);