Skip to content

Commit c6b972e

Browse files
glebmxzyfer
authored andcommitted
Avoid clang warning: expression with side effects will be evaluated despite being used as an operand to 'typeid'
This is not a useful warning here but simply extracting `*schema->at(0)` to a variable avoids it. Warning example: https://travis-ci.org/sass/libsass/jobs/471245025 Refs #1523
1 parent 2c47dbb commit c6b972e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ast_selectors.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,15 +88,19 @@ namespace Sass {
8888
bool Selector_Schema::has_parent_ref() const
8989
{
9090
if (String_Schema_Obj schema = Cast<String_Schema>(contents())) {
91-
return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Selector);
91+
if (schema->empty()) return false;
92+
const auto& first = *schema->at(0);
93+
return typeid(first) == typeid(Parent_Selector);
9294
}
9395
return false;
9496
}
9597

9698
bool Selector_Schema::has_real_parent_ref() const
9799
{
98100
if (String_Schema_Obj schema = Cast<String_Schema>(contents())) {
99-
return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Reference);
101+
if (schema->empty()) return false;
102+
const auto& first = *schema->at(0);
103+
return typeid(first) == typeid(Parent_Reference);
100104
}
101105
return false;
102106
}

0 commit comments

Comments
 (0)