@@ -113,7 +113,7 @@ TIntermSymbol* TIntermediate::addSymbol(const TType& type, const TSourceLoc& loc
113
113
//
114
114
// Returns nullptr if the working conversions and promotions could not be found.
115
115
//
116
- TIntermTyped* TIntermediate::addBinaryMath (TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc)
116
+ TIntermTyped* TIntermediate::addBinaryMath (TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc& loc)
117
117
{
118
118
// No operations work on blocks
119
119
if (left->getType ().getBasicType () == EbtBlock || right->getType ().getBasicType () == EbtBlock)
@@ -226,13 +226,12 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
226
226
//
227
227
// Low level: add binary node (no promotions or other argument modifications)
228
228
//
229
- TIntermBinary* TIntermediate::addBinaryNode (TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc) const
229
+ TIntermBinary* TIntermediate::addBinaryNode (TOperator op, TIntermTyped* left, TIntermTyped* right,
230
+ const TSourceLoc& loc) const
230
231
{
231
232
// build the node
232
233
TIntermBinary* node = new TIntermBinary (op);
233
- if (loc.line == 0 )
234
- loc = left->getLoc ();
235
- node->setLoc (loc);
234
+ node->setLoc (loc.line != 0 ? loc : left->getLoc ());
236
235
node->setLeft (left);
237
236
node->setRight (right);
238
237
@@ -242,7 +241,8 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
242
241
//
243
242
// like non-type form, but sets node's type.
244
243
//
245
- TIntermBinary* TIntermediate::addBinaryNode (TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc, const TType& type) const
244
+ TIntermBinary* TIntermediate::addBinaryNode (TOperator op, TIntermTyped* left, TIntermTyped* right,
245
+ const TSourceLoc& loc, const TType& type) const
246
246
{
247
247
TIntermBinary* node = addBinaryNode (op, left, right, loc);
248
248
node->setType (type);
@@ -252,12 +252,10 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
252
252
//
253
253
// Low level: add unary node (no promotions or other argument modifications)
254
254
//
255
- TIntermUnary* TIntermediate::addUnaryNode (TOperator op, TIntermTyped* child, TSourceLoc loc) const
255
+ TIntermUnary* TIntermediate::addUnaryNode (TOperator op, TIntermTyped* child, const TSourceLoc& loc) const
256
256
{
257
257
TIntermUnary* node = new TIntermUnary (op);
258
- if (loc.line == 0 )
259
- loc = child->getLoc ();
260
- node->setLoc (loc);
258
+ node->setLoc (loc.line != 0 ? loc : child->getLoc ());
261
259
node->setOperand (child);
262
260
263
261
return node;
@@ -266,7 +264,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
266
264
//
267
265
// like non-type form, but sets node's type.
268
266
//
269
- TIntermUnary* TIntermediate::addUnaryNode (TOperator op, TIntermTyped* child, TSourceLoc loc, const TType& type) const
267
+ TIntermUnary* TIntermediate::addUnaryNode (TOperator op, TIntermTyped* child, const TSourceLoc& loc, const TType& type)
268
+ const
270
269
{
271
270
TIntermUnary* node = addUnaryNode (op, child, loc);
272
271
node->setType (type);
@@ -281,7 +280,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
281
280
// Returns nullptr if the 'right' type could not be converted to match the 'left' type,
282
281
// or the resulting operation cannot be properly promoted.
283
282
//
284
- TIntermTyped* TIntermediate::addAssign (TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc loc)
283
+ TIntermTyped* TIntermediate::addAssign (TOperator op, TIntermTyped* left, TIntermTyped* right,
284
+ const TSourceLoc& loc)
285
285
{
286
286
// No block assignment
287
287
if (left->getType ().getBasicType () == EbtBlock || right->getType ().getBasicType () == EbtBlock)
@@ -338,7 +338,8 @@ TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TInterm
338
338
// Returns the added node.
339
339
// The caller should set the type of the returned node.
340
340
//
341
- TIntermTyped* TIntermediate::addIndex (TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc loc)
341
+ TIntermTyped* TIntermediate::addIndex (TOperator op, TIntermTyped* base, TIntermTyped* index,
342
+ const TSourceLoc& loc)
342
343
{
343
344
// caller should set the type
344
345
return addBinaryNode (op, base, index, loc);
@@ -349,7 +350,8 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
349
350
//
350
351
// Returns the added node.
351
352
//
352
- TIntermTyped* TIntermediate::addUnaryMath (TOperator op, TIntermTyped* child, TSourceLoc loc)
353
+ TIntermTyped* TIntermediate::addUnaryMath (TOperator op, TIntermTyped* child,
354
+ const TSourceLoc& loc)
353
355
{
354
356
if (child == 0 )
355
357
return nullptr ;
@@ -495,7 +497,8 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(const TSourceLoc& loc, TOper
495
497
// Returns an aggregate node, which could be the one passed in if
496
498
// it was already an aggregate.
497
499
//
498
- TIntermTyped* TIntermediate::setAggregateOperator (TIntermNode* node, TOperator op, const TType& type, TSourceLoc loc)
500
+ TIntermTyped* TIntermediate::setAggregateOperator (TIntermNode* node, TOperator op, const TType& type,
501
+ const TSourceLoc& loc)
499
502
{
500
503
TIntermAggregate* aggNode;
501
504
@@ -510,8 +513,6 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
510
513
//
511
514
aggNode = new TIntermAggregate ();
512
515
aggNode->getSequence ().push_back (node);
513
- if (loc.line == 0 )
514
- loc = node->getLoc ();
515
516
}
516
517
} else
517
518
aggNode = new TIntermAggregate ();
@@ -520,8 +521,8 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
520
521
// Set the operator.
521
522
//
522
523
aggNode->setOperator (op);
523
- if (loc.line != 0 )
524
- aggNode->setLoc (loc);
524
+ if (loc.line != 0 || node != nullptr )
525
+ aggNode->setLoc (loc. line != 0 ? loc : node-> getLoc () );
525
526
526
527
aggNode->setType (type);
527
528
0 commit comments