Commit ff937edd authored by danakj's avatar danakj Committed by Commit bot

rewrite_to_chrome_style: Avoid asserts when checking for const-ness.

Just skip expressions that are dependent on template parameters, treat
them as non-constant.

R=dcheng
BUG=581218

Review URL: https://codereview.chromium.org/1645243002

Cr-Commit-Position: refs/heads/master@{#372256}
parent d5e1e732
...@@ -157,6 +157,15 @@ bool IsProbablyConst(const clang::VarDecl& decl, ...@@ -157,6 +157,15 @@ bool IsProbablyConst(const clang::VarDecl& decl,
if (!initializer) if (!initializer)
return false; return false;
// If the expression is dependent on a template input, then we are not
// sure if it can be compile-time generated as calling isEvaluatable() is
// not valid on |initializer|.
// TODO(crbug.com/581218): We could probably look at each compiled
// instantiation of the template and see if they are all compile-time
// isEvaluable().
if (initializer->isInstantiationDependent())
return false;
// If the expression can be evaluated at compile time, then it should have a // If the expression can be evaluated at compile time, then it should have a
// kFoo style name. Otherwise, not. // kFoo style name. Otherwise, not.
return initializer->isEvaluatable(context); return initializer->isEvaluatable(context);
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace blink {
template <typename T, int number>
void F() {
// We don't assert on this, and we don't end up considering it a const for
// now.
const int maybe_a_const = sizeof(T);
const int is_a_const = number;
}
template <int number, typename... T>
void F() {
// We don't assert on this, and we don't end up considering it a const for
// now.
const int maybe_a_const = sizeof...(T);
const int is_a_const = number;
}
} // namespace blink
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
namespace blink {
template <typename T, int number>
void F() {
// We don't assert on this, and we don't end up considering it a const for
// now.
const int maybe_a_const = sizeof(T);
const int is_a_const = number;
}
template <int number, typename... T>
void F() {
// We don't assert on this, and we don't end up considering it a const for
// now.
const int maybe_a_const = sizeof...(T);
const int is_a_const = number;
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment