Bug Summary

File:root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp
Warning:line 384, column 65
Called C++ object pointer is null

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name ValidateLimitations.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -ffp-contract=off -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -target-feature +sse2 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/angle/targets/translator -fcoverage-compilation-dir=/root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/angle/targets/translator -resource-dir /usr/lib/llvm-21/lib/clang/21 -include /root/firefox-clang/config/gcc_hidden.h -include /root/firefox-clang/obj-x86_64-pc-linux-gnu/mozilla-config.h -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/stl_wrappers -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/system_wrappers -U _FORTIFY_SOURCE -D _FORTIFY_SOURCE=2 -D _GLIBCXX_ASSERTIONS -D DEBUG=1 -D ANGLE_PLATFORM_EXPORT= -D __NDK_FPABI__= -D ANGLE_SKIP_DXGI_1_2_CHECK -D ANGLE_ENABLE_KEYEDMUTEX -D ANGLE_TRANSLATOR_ESSL_ONLY -D ANGLE_DISABLE_POOL_ALLOC -D ANGLE_ENABLE_APPLE_WORKAROUNDS -D ANGLE_ENABLE_ESSL -D ANGLE_ENABLE_GLSL -D ANGLE_ENABLE_HLSL -D ANGLE_ENABLE_SHARE_CONTEXT_LOCK=1 -D ANGLE_VMA_VERSION=2003000 -D CR_CLANG_REVISION="llvmorg-16-init-6578-g0d30e92f-2" -D DYNAMIC_ANNOTATIONS_ENABLED=0 -D NOMINMAX -D UNICODE -D WINVER=0x0A00 -D _ATL_NO_OPENGL -D _CRT_NONSTDC_NO_WARNINGS -D _CRT_RAND_S -D _CRT_SECURE_NO_DEPRECATE -D _HAS_EXCEPTIONS=0 -D _SCL_SECURE_NO_DEPRECATE -D _SECURE_ATL -D _UNICODE -D _WINSOCK_DEPRECATED_NO_WARNINGS -I /root/firefox-clang/gfx/angle/targets/translator -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/gfx/angle/targets/translator -I /root/firefox-clang/gfx/angle/checkout/include -I /root/firefox-clang/gfx/angle/checkout/src -I /root/firefox-clang/gfx/angle/checkout/src/common/third_party/base -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nspr -I /root/firefox-clang/obj-x86_64-pc-linux-gnu/dist/include/nss -D MOZILLA_CLIENT -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-21/lib/clang/21/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -Wno-error=pessimizing-move -Wno-error=large-by-value-copy=128 -Wno-error=implicit-int-float-conversion -Wno-error=thread-safety-analysis -Wno-error=tautological-type-limit-compare -Wno-invalid-offsetof -Wno-range-loop-analysis -Wno-deprecated-anon-enum-enum-conversion -Wno-deprecated-enum-enum-conversion -Wno-deprecated-this-capture -Wno-inline-new-delete -Wno-error=deprecated-declarations -Wno-error=array-bounds -Wno-error=free-nonheap-object -Wno-error=atomic-alignment -Wno-error=deprecated-builtins -Wno-psabi -Wno-error=builtin-macro-redefined -Wno-vla-cxx-extension -Wno-unknown-warning-option -Wno-final-dtor-non-final-class -Wno-implicit-const-int-float-conversion -Wno-range-loop-construct -fdeprecated-macro -ferror-limit 19 -fstrict-flex-arrays=1 -stack-protector 2 -fstack-clash-protection -ftrivial-auto-var-init=pattern -fno-rtti -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fno-sized-deallocation -fno-aligned-allocation -vectorize-loops -vectorize-slp -analyzer-checker optin.performance.Padding -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2025-06-27-100320-3286336-1 -x c++ /root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp
1//
2// Copyright 2002 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7#include "compiler/translator/ValidateLimitations.h"
8
9#include "angle_gl.h"
10#include "compiler/translator/Diagnostics.h"
11#include "compiler/translator/ParseContext.h"
12#include "compiler/translator/tree_util/IntermTraverse.h"
13
14namespace sh
15{
16
17namespace
18{
19
20int GetLoopSymbolId(TIntermLoop *loop)
21{
22 // Here we assume all the operations are valid, because the loop node is
23 // already validated before this call.
24 TIntermSequence *declSeq = loop->getInit()->getAsDeclarationNode()->getSequence();
25 TIntermBinary *declInit = (*declSeq)[0]->getAsBinaryNode();
26 TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode();
27
28 return symbol->uniqueId().get();
29}
30
31// Traverses a node to check if it represents a constant index expression.
32// Definition:
33// constant-index-expressions are a superset of constant-expressions.
34// Constant-index-expressions can include loop indices as defined in
35// GLSL ES 1.0 spec, Appendix A, section 4.
36// The following are constant-index-expressions:
37// - Constant expressions
38// - Loop indices as defined in section 4
39// - Expressions composed of both of the above
40class ValidateConstIndexExpr : public TIntermTraverser
41{
42 public:
43 ValidateConstIndexExpr(const std::vector<int> &loopSymbols)
44 : TIntermTraverser(true, false, false), mValid(true), mLoopSymbolIds(loopSymbols)
45 {}
46
47 // Returns true if the parsed node represents a constant index expression.
48 bool isValid() const { return mValid; }
49
50 void visitSymbol(TIntermSymbol *symbol) override
51 {
52 // Only constants and loop indices are allowed in a
53 // constant index expression.
54 if (mValid)
55 {
56 bool isLoopSymbol = std::find(mLoopSymbolIds.begin(), mLoopSymbolIds.end(),
57 symbol->uniqueId().get()) != mLoopSymbolIds.end();
58 mValid = (symbol->getQualifier() == EvqConst) || isLoopSymbol;
59 }
60 }
61
62 private:
63 bool mValid;
64 const std::vector<int> mLoopSymbolIds;
65};
66
67// Traverses intermediate tree to ensure that the shader does not exceed the
68// minimum functionality mandated in GLSL 1.0 spec, Appendix A.
69class ValidateLimitationsTraverser : public TLValueTrackingTraverser
70{
71 public:
72 ValidateLimitationsTraverser(sh::GLenum shaderType,
73 TSymbolTable *symbolTable,
74 TDiagnostics *diagnostics);
75
76 void visitSymbol(TIntermSymbol *node) override;
77 bool visitBinary(Visit, TIntermBinary *) override;
78 bool visitLoop(Visit, TIntermLoop *) override;
79
80 private:
81 void error(TSourceLoc loc, const char *reason, const char *token);
82 void error(TSourceLoc loc, const char *reason, const ImmutableString &token);
83
84 bool isLoopIndex(TIntermSymbol *symbol);
85 bool validateLoopType(TIntermLoop *node);
86
87 bool validateForLoopHeader(TIntermLoop *node);
88 // If valid, return the index symbol id; Otherwise, return -1.
89 int validateForLoopInit(TIntermLoop *node);
90 bool validateForLoopCond(TIntermLoop *node, int indexSymbolId);
91 bool validateForLoopExpr(TIntermLoop *node, int indexSymbolId);
92
93 // Returns true if indexing does not exceed the minimum functionality
94 // mandated in GLSL 1.0 spec, Appendix A, Section 5.
95 bool isConstExpr(TIntermNode *node);
96 bool isConstIndexExpr(TIntermNode *node);
97 bool validateIndexing(TIntermBinary *node);
98
99 sh::GLenum mShaderType;
100 TDiagnostics *mDiagnostics;
101 std::vector<int> mLoopSymbolIds;
102};
103
104ValidateLimitationsTraverser::ValidateLimitationsTraverser(sh::GLenum shaderType,
105 TSymbolTable *symbolTable,
106 TDiagnostics *diagnostics)
107 : TLValueTrackingTraverser(true, false, false, symbolTable),
108 mShaderType(shaderType),
109 mDiagnostics(diagnostics)
110{
111 ASSERT(diagnostics)(diagnostics ? static_cast<void>(0) : (!((::gl::priv::ShouldCreatePlatformLogMessage
(::gl::LOG_FATAL))) ? static_cast<void>(0) : ::gl::priv
::LogMessageVoidify() & (::gl::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 111, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 111 << "): " << "diagnostics"
))
;
112}
113
114void ValidateLimitationsTraverser::visitSymbol(TIntermSymbol *node)
115{
116 if (isLoopIndex(node) && isLValueRequiredHere())
117 {
118 error(node->getLine(),
119 "Loop index cannot be statically assigned to within the body of the loop",
120 node->getName());
121 }
122}
123
124bool ValidateLimitationsTraverser::visitBinary(Visit, TIntermBinary *node)
125{
126 // Check indexing.
127 switch (node->getOp())
128 {
129 case EOpIndexDirect:
130 case EOpIndexIndirect:
131 validateIndexing(node);
132 break;
133 default:
134 break;
135 }
136 return true;
137}
138
139bool ValidateLimitationsTraverser::visitLoop(Visit, TIntermLoop *node)
140{
141 if (!validateLoopType(node))
1
Taking false branch
142 return false;
143
144 if (!validateForLoopHeader(node))
2
Calling 'ValidateLimitationsTraverser::validateForLoopHeader'
145 return false;
146
147 TIntermNode *body = node->getBody();
148 if (body != nullptr)
149 {
150 mLoopSymbolIds.push_back(GetLoopSymbolId(node));
151 body->traverse(this);
152 mLoopSymbolIds.pop_back();
153 }
154
155 // The loop is fully processed - no need to visit children.
156 return false;
157}
158
159void ValidateLimitationsTraverser::error(TSourceLoc loc, const char *reason, const char *token)
160{
161 mDiagnostics->error(loc, reason, token);
162}
163
164void ValidateLimitationsTraverser::error(TSourceLoc loc,
165 const char *reason,
166 const ImmutableString &token)
167{
168 error(loc, reason, token.data());
169}
170
171bool ValidateLimitationsTraverser::isLoopIndex(TIntermSymbol *symbol)
172{
173 return std::find(mLoopSymbolIds.begin(), mLoopSymbolIds.end(), symbol->uniqueId().get()) !=
174 mLoopSymbolIds.end();
175}
176
177bool ValidateLimitationsTraverser::validateLoopType(TIntermLoop *node)
178{
179 TLoopType type = node->getType();
180 if (type == ELoopFor)
181 return true;
182
183 // Reject while and do-while loops.
184 error(node->getLine(), "This type of loop is not allowed", type == ELoopWhile ? "while" : "do");
185 return false;
186}
187
188bool ValidateLimitationsTraverser::validateForLoopHeader(TIntermLoop *node)
189{
190 ASSERT(node->getType() == ELoopFor)(node->getType() == ELoopFor ? static_cast<void>(0) :
(!((::gl::priv::ShouldCreatePlatformLogMessage(::gl::LOG_FATAL
))) ? static_cast<void>(0) : ::gl::priv::LogMessageVoidify
() & (::gl::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 190, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 190 << "): " << "node->getType() == ELoopFor"
))
;
3
'?' condition is true
191
192 //
193 // The for statement has the form:
194 // for ( init-declaration ; condition ; expression ) statement
195 //
196 int indexSymbolId = validateForLoopInit(node);
197 if (indexSymbolId < 0)
4
Assuming 'indexSymbolId' is >= 0
5
Taking false branch
198 return false;
199 if (!validateForLoopCond(node, indexSymbolId))
6
Taking false branch
200 return false;
201 if (!validateForLoopExpr(node, indexSymbolId))
7
Calling 'ValidateLimitationsTraverser::validateForLoopExpr'
202 return false;
203
204 return true;
205}
206
207int ValidateLimitationsTraverser::validateForLoopInit(TIntermLoop *node)
208{
209 TIntermNode *init = node->getInit();
210 if (init == nullptr)
211 {
212 error(node->getLine(), "Missing init declaration", "for");
213 return -1;
214 }
215
216 //
217 // init-declaration has the form:
218 // type-specifier identifier = constant-expression
219 //
220 TIntermDeclaration *decl = init->getAsDeclarationNode();
221 if (decl == nullptr)
222 {
223 error(init->getLine(), "Invalid init declaration", "for");
224 return -1;
225 }
226 // To keep things simple do not allow declaration list.
227 TIntermSequence *declSeq = decl->getSequence();
228 if (declSeq->size() != 1)
229 {
230 error(decl->getLine(), "Invalid init declaration", "for");
231 return -1;
232 }
233 TIntermBinary *declInit = (*declSeq)[0]->getAsBinaryNode();
234 if ((declInit == nullptr) || (declInit->getOp() != EOpInitialize))
235 {
236 error(decl->getLine(), "Invalid init declaration", "for");
237 return -1;
238 }
239 TIntermSymbol *symbol = declInit->getLeft()->getAsSymbolNode();
240 if (symbol == nullptr)
241 {
242 error(declInit->getLine(), "Invalid init declaration", "for");
243 return -1;
244 }
245 // The loop index has type int or float.
246 TBasicType type = symbol->getBasicType();
247 if ((type != EbtInt) && (type != EbtUInt) && (type != EbtFloat))
248 {
249 error(symbol->getLine(), "Invalid type for loop index", getBasicString(type));
250 return -1;
251 }
252 // The loop index is initialized with constant expression.
253 if (!isConstExpr(declInit->getRight()))
254 {
255 error(declInit->getLine(), "Loop index cannot be initialized with non-constant expression",
256 symbol->getName());
257 return -1;
258 }
259
260 return symbol->uniqueId().get();
261}
262
263bool ValidateLimitationsTraverser::validateForLoopCond(TIntermLoop *node, int indexSymbolId)
264{
265 TIntermNode *cond = node->getCondition();
266 if (cond == nullptr)
267 {
268 error(node->getLine(), "Missing condition", "for");
269 return false;
270 }
271 //
272 // condition has the form:
273 // loop_index relational_operator constant_expression
274 //
275 TIntermBinary *binOp = cond->getAsBinaryNode();
276 if (binOp == nullptr)
277 {
278 error(node->getLine(), "Invalid condition", "for");
279 return false;
280 }
281 // Loop index should be to the left of relational operator.
282 TIntermSymbol *symbol = binOp->getLeft()->getAsSymbolNode();
283 if (symbol == nullptr)
284 {
285 error(binOp->getLine(), "Invalid condition", "for");
286 return false;
287 }
288 if (symbol->uniqueId().get() != indexSymbolId)
289 {
290 error(symbol->getLine(), "Expected loop index", symbol->getName());
291 return false;
292 }
293 // Relational operator is one of: > >= < <= == or !=.
294 switch (binOp->getOp())
295 {
296 case EOpEqual:
297 case EOpNotEqual:
298 case EOpLessThan:
299 case EOpGreaterThan:
300 case EOpLessThanEqual:
301 case EOpGreaterThanEqual:
302 break;
303 default:
304 error(binOp->getLine(), "Invalid relational operator",
305 GetOperatorString(binOp->getOp()));
306 break;
307 }
308 // Loop index must be compared with a constant.
309 if (!isConstExpr(binOp->getRight()))
310 {
311 error(binOp->getLine(), "Loop index cannot be compared with non-constant expression",
312 symbol->getName());
313 return false;
314 }
315
316 return true;
317}
318
319bool ValidateLimitationsTraverser::validateForLoopExpr(TIntermLoop *node, int indexSymbolId)
320{
321 TIntermNode *expr = node->getExpression();
322 if (expr == nullptr)
8
Assuming the condition is false
9
Taking false branch
323 {
324 error(node->getLine(), "Missing expression", "for");
325 return false;
326 }
327
328 // for expression has one of the following forms:
329 // loop_index++
330 // loop_index--
331 // loop_index += constant_expression
332 // loop_index -= constant_expression
333 // ++loop_index
334 // --loop_index
335 // The last two forms are not specified in the spec, but I am assuming
336 // its an oversight.
337 TIntermUnary *unOp = expr->getAsUnaryNode();
338 TIntermBinary *binOp = unOp ? nullptr : expr->getAsBinaryNode();
10
Assuming 'unOp' is null
11
'?' condition is false
339
340 TOperator op = EOpNull;
341 const TFunction *opFunc = nullptr;
12
'opFunc' initialized to a null pointer value
342 TIntermSymbol *symbol = nullptr;
343 if (unOp != nullptr)
13
Taking false branch
344 {
345 op = unOp->getOp();
346 opFunc = unOp->getFunction();
347 symbol = unOp->getOperand()->getAsSymbolNode();
348 }
349 else if (binOp != nullptr)
14
Assuming the condition is true
15
Taking true branch
350 {
351 op = binOp->getOp();
352 symbol = binOp->getLeft()->getAsSymbolNode();
353 }
354
355 // The operand must be loop index.
356 if (symbol == nullptr)
16
Assuming the condition is false
17
Taking false branch
357 {
358 error(expr->getLine(), "Invalid expression", "for");
359 return false;
360 }
361 if (symbol->uniqueId().get() != indexSymbolId)
18
Assuming the condition is false
19
Taking false branch
362 {
363 error(symbol->getLine(), "Expected loop index", symbol->getName());
364 return false;
365 }
366
367 // The operator is one of: ++ -- += -=.
368 switch (op)
20
Control jumps to the 'default' case at line 380
369 {
370 case EOpPostIncrement:
371 case EOpPostDecrement:
372 case EOpPreIncrement:
373 case EOpPreDecrement:
374 ASSERT((unOp != nullptr) && (binOp == nullptr))((unOp != nullptr) && (binOp == nullptr) ? static_cast
<void>(0) : (!((::gl::priv::ShouldCreatePlatformLogMessage
(::gl::LOG_FATAL))) ? static_cast<void>(0) : ::gl::priv
::LogMessageVoidify() & (::gl::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 374, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 374 << "): " << "(unOp != nullptr) && (binOp == nullptr)"
))
;
375 break;
376 case EOpAddAssign:
377 case EOpSubAssign:
378 ASSERT((unOp == nullptr) && (binOp != nullptr))((unOp == nullptr) && (binOp != nullptr) ? static_cast
<void>(0) : (!((::gl::priv::ShouldCreatePlatformLogMessage
(::gl::LOG_FATAL))) ? static_cast<void>(0) : ::gl::priv
::LogMessageVoidify() & (::gl::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 378, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 378 << "): " << "(unOp == nullptr) && (binOp != nullptr)"
))
;
379 break;
380 default:
381 if (BuiltInGroup::IsBuiltIn(op))
21
Taking true branch
382 {
383 ASSERT(opFunc != nullptr)(opFunc != nullptr ? static_cast<void>(0) : (!((::gl::priv
::ShouldCreatePlatformLogMessage(::gl::LOG_FATAL))) ? static_cast
<void>(0) : ::gl::priv::LogMessageVoidify() & (::gl
::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 383, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 383 << "): " << "opFunc != nullptr"
))
;
22
'?' condition is false
23
Assuming the condition is true
24
'?' condition is true
384 error(expr->getLine(), "Invalid built-in call", opFunc->name().data());
25
Called C++ object pointer is null
385 }
386 else
387 {
388 error(expr->getLine(), "Invalid operator", GetOperatorString(op));
389 }
390 return false;
391 }
392
393 // Loop index must be incremented/decremented with a constant.
394 if (binOp != nullptr)
395 {
396 if (!isConstExpr(binOp->getRight()))
397 {
398 error(binOp->getLine(), "Loop index cannot be modified by non-constant expression",
399 symbol->getName());
400 return false;
401 }
402 }
403
404 return true;
405}
406
407bool ValidateLimitationsTraverser::isConstExpr(TIntermNode *node)
408{
409 ASSERT(node != nullptr)(node != nullptr ? static_cast<void>(0) : (!((::gl::priv
::ShouldCreatePlatformLogMessage(::gl::LOG_FATAL))) ? static_cast
<void>(0) : ::gl::priv::LogMessageVoidify() & (::gl
::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 409, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 409 << "): " << "node != nullptr"
))
;
410 return node->getAsConstantUnion() != nullptr && node->getAsTyped()->getQualifier() == EvqConst;
411}
412
413bool ValidateLimitationsTraverser::isConstIndexExpr(TIntermNode *node)
414{
415 ASSERT(node != nullptr)(node != nullptr ? static_cast<void>(0) : (!((::gl::priv
::ShouldCreatePlatformLogMessage(::gl::LOG_FATAL))) ? static_cast
<void>(0) : ::gl::priv::LogMessageVoidify() & (::gl
::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 415, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 415 << "): " << "node != nullptr"
))
;
416
417 ValidateConstIndexExpr validate(mLoopSymbolIds);
418 node->traverse(&validate);
419 return validate.isValid();
420}
421
422bool ValidateLimitationsTraverser::validateIndexing(TIntermBinary *node)
423{
424 ASSERT((node->getOp() == EOpIndexDirect) || (node->getOp() == EOpIndexIndirect))((node->getOp() == EOpIndexDirect) || (node->getOp() ==
EOpIndexIndirect) ? static_cast<void>(0) : (!((::gl::priv
::ShouldCreatePlatformLogMessage(::gl::LOG_FATAL))) ? static_cast
<void>(0) : ::gl::priv::LogMessageVoidify() & (::gl
::LogMessage("/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
, __FUNCTION__, 424, ::gl::LOG_FATAL).stream()) << "\t! Assert failed in "
<< __FUNCTION__ << " (" << "/root/firefox-clang/gfx/angle/checkout/src/compiler/translator/ValidateLimitations.cpp"
<< ":" << 424 << "): " << "(node->getOp() == EOpIndexDirect) || (node->getOp() == EOpIndexIndirect)"
))
;
425
426 bool valid = true;
427 TIntermTyped *index = node->getRight();
428 // The index expession must be a constant-index-expression unless
429 // the operand is a uniform in a vertex shader.
430 TIntermTyped *operand = node->getLeft();
431 bool skip = (mShaderType == GL_VERTEX_SHADER0x8B31) && (operand->getQualifier() == EvqUniform);
432 if (!skip && !isConstIndexExpr(index))
433 {
434 error(index->getLine(), "Index expression must be constant", "[]");
435 valid = false;
436 }
437 return valid;
438}
439
440} // namespace
441
442bool ValidateLimitations(TIntermNode *root,
443 GLenum shaderType,
444 TSymbolTable *symbolTable,
445 TDiagnostics *diagnostics)
446{
447 ValidateLimitationsTraverser validate(shaderType, symbolTable, diagnostics);
448 root->traverse(&validate);
449 return diagnostics->numErrors() == 0;
450}
451
452} // namespace sh