Skip to content

Commit 4d616c7

Browse files
authored
[SPIR-V][NFC] Add const to many FeatureManager fns (#7980)
Many feature manager functions are const getters, and should be marked as such allowing using FeatureManager as const ref.
1 parent 79813b5 commit 4d616c7

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

tools/clang/include/clang/SPIRV/FeatureManager.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class FeatureManager {
9292
const char *getExtensionName(Extension symbol);
9393

9494
/// Returns true if the given extension is a KHR extension.
95-
bool isKHRExtension(llvm::StringRef name);
95+
bool isKHRExtension(llvm::StringRef name) const;
9696

9797
/// Returns the names of all known extensions as a string.
9898
std::string getKnownExtensions(const char *delimiter, const char *prefix = "",
@@ -110,33 +110,33 @@ class FeatureManager {
110110

111111
/// Returns true if the given extension is not part of the core of the target
112112
/// environment.
113-
bool isExtensionRequiredForTargetEnv(Extension);
113+
bool isExtensionRequiredForTargetEnv(Extension) const;
114114

115115
/// Returns true if the given extension is set in allowedExtensions
116-
bool isExtensionEnabled(Extension);
116+
bool isExtensionEnabled(Extension) const;
117117

118118
/// Returns true if the target environment is Vulkan 1.1 or above.
119119
/// Returns false otherwise.
120-
bool isTargetEnvVulkan1p1OrAbove();
120+
bool isTargetEnvVulkan1p1OrAbove() const;
121121

122122
/// Returns true if the target environment is SPIR-V 1.4 or above.
123123
/// Returns false otherwise.
124-
bool isTargetEnvSpirv1p4OrAbove();
124+
bool isTargetEnvSpirv1p4OrAbove() const;
125125

126126
/// Returns true if the target environment is Vulkan 1.1 with SPIR-V 1.4 or
127127
/// above. Returns false otherwise.
128-
bool isTargetEnvVulkan1p1Spirv1p4OrAbove();
128+
bool isTargetEnvVulkan1p1Spirv1p4OrAbove() const;
129129

130130
/// Returns true if the target environment is Vulkan 1.2 or above.
131131
/// Returns false otherwise.
132-
bool isTargetEnvVulkan1p2OrAbove();
132+
bool isTargetEnvVulkan1p2OrAbove() const;
133133

134134
/// Returns true if the target environment is Vulkan 1.3 or above.
135135
/// Returns false otherwise.
136-
bool isTargetEnvVulkan1p3OrAbove();
136+
bool isTargetEnvVulkan1p3OrAbove() const;
137137

138138
/// Return true if the target environment is a Vulkan environment.
139-
bool isTargetEnvVulkan();
139+
bool isTargetEnvVulkan() const;
140140

141141
/// Returns the spv_target_env matching the input string if possible.
142142
/// This functions matches the spv_target_env with the command-line version

tools/clang/lib/SPIRV/FeatureManager.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ const char *FeatureManager::getExtensionName(Extension symbol) {
309309
return "<unknown extension>";
310310
}
311311

312-
bool FeatureManager::isKHRExtension(llvm::StringRef name) {
312+
bool FeatureManager::isKHRExtension(llvm::StringRef name) const {
313313
return name.startswith_lower("spv_khr_");
314314
}
315315

@@ -332,7 +332,7 @@ std::string FeatureManager::getKnownExtensions(const char *delimiter,
332332
return oss.str();
333333
}
334334

335-
bool FeatureManager::isExtensionRequiredForTargetEnv(Extension ext) {
335+
bool FeatureManager::isExtensionRequiredForTargetEnv(Extension ext) const {
336336
bool required = true;
337337
if (targetEnv >= SPV_ENV_VULKAN_1_3) {
338338
// The following extensions are incorporated into Vulkan 1.3 or above, and
@@ -367,7 +367,7 @@ bool FeatureManager::isExtensionRequiredForTargetEnv(Extension ext) {
367367
return required;
368368
}
369369

370-
bool FeatureManager::isExtensionEnabled(Extension ext) {
370+
bool FeatureManager::isExtensionEnabled(Extension ext) const {
371371
bool allowed = false;
372372
if (ext != Extension::Unknown &&
373373
allowedExtensions.test(static_cast<unsigned>(ext)))
@@ -399,27 +399,27 @@ bool FeatureManager::enabledByDefault(Extension ext) {
399399
}
400400
}
401401

402-
bool FeatureManager::isTargetEnvVulkan1p1OrAbove() {
402+
bool FeatureManager::isTargetEnvVulkan1p1OrAbove() const {
403403
return targetEnv >= SPV_ENV_VULKAN_1_1;
404404
}
405405

406-
bool FeatureManager::isTargetEnvSpirv1p4OrAbove() {
406+
bool FeatureManager::isTargetEnvSpirv1p4OrAbove() const {
407407
return targetEnv >= SPV_ENV_UNIVERSAL_1_4;
408408
}
409409

410-
bool FeatureManager::isTargetEnvVulkan1p1Spirv1p4OrAbove() {
410+
bool FeatureManager::isTargetEnvVulkan1p1Spirv1p4OrAbove() const {
411411
return targetEnv >= SPV_ENV_VULKAN_1_1_SPIRV_1_4;
412412
}
413413

414-
bool FeatureManager::isTargetEnvVulkan1p2OrAbove() {
414+
bool FeatureManager::isTargetEnvVulkan1p2OrAbove() const {
415415
return targetEnv >= SPV_ENV_VULKAN_1_2;
416416
}
417417

418-
bool FeatureManager::isTargetEnvVulkan1p3OrAbove() {
418+
bool FeatureManager::isTargetEnvVulkan1p3OrAbove() const {
419419
return targetEnv >= SPV_ENV_VULKAN_1_3;
420420
}
421421

422-
bool FeatureManager::isTargetEnvVulkan() {
422+
bool FeatureManager::isTargetEnvVulkan() const {
423423
// This assert ensure that this list will be updated, if necessary, when
424424
// a new target environment is added.
425425
static_assert(SPV_ENV_VULKAN_1_4 + 1 == SPV_ENV_MAX);

0 commit comments

Comments
 (0)