Skip to content

Commit 6c37bbb

Browse files
committed
Non-functional: consistently use 'const TSourceLoc&' to pass location.
1 parent b60e067 commit 6c37bbb

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

glslang/MachineIndependent/Intermediate.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ TIntermSymbol* TIntermediate::addSymbol(const TType& type, const TSourceLoc& loc
113113
//
114114
// Returns nullptr if the working conversions and promotions could not be found.
115115
//
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)
117117
{
118118
// No operations work on blocks
119119
if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
@@ -226,13 +226,12 @@ TIntermTyped* TIntermediate::addBinaryMath(TOperator op, TIntermTyped* left, TIn
226226
//
227227
// Low level: add binary node (no promotions or other argument modifications)
228228
//
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
230231
{
231232
// build the node
232233
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());
236235
node->setLeft(left);
237236
node->setRight(right);
238237

@@ -242,7 +241,8 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
242241
//
243242
// like non-type form, but sets node's type.
244243
//
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
246246
{
247247
TIntermBinary* node = addBinaryNode(op, left, right, loc);
248248
node->setType(type);
@@ -252,12 +252,10 @@ TIntermBinary* TIntermediate::addBinaryNode(TOperator op, TIntermTyped* left, TI
252252
//
253253
// Low level: add unary node (no promotions or other argument modifications)
254254
//
255-
TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc loc) const
255+
TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc& loc) const
256256
{
257257
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());
261259
node->setOperand(child);
262260

263261
return node;
@@ -266,7 +264,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
266264
//
267265
// like non-type form, but sets node's type.
268266
//
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
270269
{
271270
TIntermUnary* node = addUnaryNode(op, child, loc);
272271
node->setType(type);
@@ -281,7 +280,8 @@ TIntermUnary* TIntermediate::addUnaryNode(TOperator op, TIntermTyped* child, TSo
281280
// Returns nullptr if the 'right' type could not be converted to match the 'left' type,
282281
// or the resulting operation cannot be properly promoted.
283282
//
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)
285285
{
286286
// No block assignment
287287
if (left->getType().getBasicType() == EbtBlock || right->getType().getBasicType() == EbtBlock)
@@ -338,7 +338,8 @@ TIntermTyped* TIntermediate::addAssign(TOperator op, TIntermTyped* left, TInterm
338338
// Returns the added node.
339339
// The caller should set the type of the returned node.
340340
//
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)
342343
{
343344
// caller should set the type
344345
return addBinaryNode(op, base, index, loc);
@@ -349,7 +350,8 @@ TIntermTyped* TIntermediate::addIndex(TOperator op, TIntermTyped* base, TIntermT
349350
//
350351
// Returns the added node.
351352
//
352-
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child, TSourceLoc loc)
353+
TIntermTyped* TIntermediate::addUnaryMath(TOperator op, TIntermTyped* child,
354+
const TSourceLoc& loc)
353355
{
354356
if (child == 0)
355357
return nullptr;
@@ -495,7 +497,8 @@ TIntermTyped* TIntermediate::addBuiltInFunctionCall(const TSourceLoc& loc, TOper
495497
// Returns an aggregate node, which could be the one passed in if
496498
// it was already an aggregate.
497499
//
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)
499502
{
500503
TIntermAggregate* aggNode;
501504

@@ -510,8 +513,6 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
510513
//
511514
aggNode = new TIntermAggregate();
512515
aggNode->getSequence().push_back(node);
513-
if (loc.line == 0)
514-
loc = node->getLoc();
515516
}
516517
} else
517518
aggNode = new TIntermAggregate();
@@ -520,8 +521,8 @@ TIntermTyped* TIntermediate::setAggregateOperator(TIntermNode* node, TOperator o
520521
// Set the operator.
521522
//
522523
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());
525526

526527
aggNode->setType(type);
527528

glslang/MachineIndependent/localintermediate.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ class TIntermediate {
430430
TIntermTyped* addConversion(TBasicType convertTo, TIntermTyped* node) const;
431431
void addBiShapeConversion(TOperator, TIntermTyped*& lhsNode, TIntermTyped*& rhsNode);
432432
TIntermTyped* addShapeConversion(const TType&, TIntermTyped*);
433-
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
434-
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc);
435-
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, TSourceLoc);
436-
TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, TSourceLoc);
433+
TIntermTyped* addBinaryMath(TOperator, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
434+
TIntermTyped* addAssign(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&);
435+
TIntermTyped* addIndex(TOperator op, TIntermTyped* base, TIntermTyped* index, const TSourceLoc&);
436+
TIntermTyped* addUnaryMath(TOperator, TIntermTyped* child, const TSourceLoc&);
437437
TIntermTyped* addBuiltInFunctionCall(const TSourceLoc& line, TOperator, bool unary, TIntermNode*, const TType& returnType);
438438
bool canImplicitlyPromote(TBasicType from, TBasicType to, TOperator op = EOpNull) const;
439439
bool isIntegralPromotion(TBasicType from, TBasicType to) const;
@@ -447,7 +447,7 @@ class TIntermediate {
447447
TIntermAggregate* makeAggregate(TIntermNode* node);
448448
TIntermAggregate* makeAggregate(TIntermNode* node, const TSourceLoc&);
449449
TIntermAggregate* makeAggregate(const TSourceLoc&);
450-
TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, TSourceLoc);
450+
TIntermTyped* setAggregateOperator(TIntermNode*, TOperator, const TType& type, const TSourceLoc&);
451451
bool areAllChildConst(TIntermAggregate* aggrNode);
452452
TIntermSelection* addSelection(TIntermTyped* cond, TIntermNodePair code, const TSourceLoc&);
453453
TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, const TSourceLoc&);
@@ -476,10 +476,11 @@ class TIntermediate {
476476

477477
// Low level functions to add nodes (no conversions or other higher level transformations)
478478
// If a type is provided, the node's type will be set to it.
479-
TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc) const;
480-
TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, TSourceLoc, const TType&) const;
481-
TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc) const;
482-
TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, TSourceLoc, const TType&) const;
479+
TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&) const;
480+
TIntermBinary* addBinaryNode(TOperator op, TIntermTyped* left, TIntermTyped* right, const TSourceLoc&,
481+
const TType&) const;
482+
TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&) const;
483+
TIntermUnary* addUnaryNode(TOperator op, TIntermTyped* child, const TSourceLoc&, const TType&) const;
483484

484485
// Constant folding (in Constant.cpp)
485486
TIntermTyped* fold(TIntermAggregate* aggrNode);

0 commit comments

Comments
 (0)