From c6b972ed47540286ca34537ceec94d7b6aac48ad Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Tue, 25 Dec 2018 03:53:18 +0000 Subject: [PATCH] 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 --- src/ast_selectors.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/ast_selectors.cpp b/src/ast_selectors.cpp index 3327350ac..98cfd5c92 100644 --- a/src/ast_selectors.cpp +++ b/src/ast_selectors.cpp @@ -88,7 +88,9 @@ namespace Sass { bool Selector_Schema::has_parent_ref() const { if (String_Schema_Obj schema = Cast(contents())) { - return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Selector); + if (schema->empty()) return false; + const auto& first = *schema->at(0); + return typeid(first) == typeid(Parent_Selector); } return false; } @@ -96,7 +98,9 @@ namespace Sass { bool Selector_Schema::has_real_parent_ref() const { if (String_Schema_Obj schema = Cast(contents())) { - return !schema->empty() && typeid(*schema->at(0)) == typeid(Parent_Reference); + if (schema->empty()) return false; + const auto& first = *schema->at(0); + return typeid(first) == typeid(Parent_Reference); } return false; }