Chromium Code Reviews| Index: base/logging.h |
| diff --git a/base/logging.h b/base/logging.h |
| index c0ebaf92bd3da3da67fa467cea0399542790debd..329e113a3436b62d0f2e900d5608f7d9169b8003 100644 |
| --- a/base/logging.h |
| +++ b/base/logging.h |
| @@ -298,8 +298,10 @@ BASE_EXPORT LogMessageHandlerFunction GetLogMessageHandler(); |
| inline void AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {} |
| +// An rvalue parameter is used because it allows both lvalue and rvalue forms of |
|
danakj
2017/02/14 20:09:16
This isn't an rvalue parameter actually, because T
Kevin M
2017/02/14 21:05:09
Updated the comments.
|
| +// |arg| to be passed as arguments. |
| template <typename TVal> |
| -inline constexpr TVal AnalysisAssumeTrue(TVal arg) { |
| +inline constexpr TVal AnalysisAssumeTrue(TVal&& arg) { |
| if (!arg) { |
| AnalyzerNoReturn(); |
| } |
| @@ -310,8 +312,10 @@ inline constexpr TVal AnalysisAssumeTrue(TVal arg) { |
| #elif defined(_PREFAST_) && defined(OS_WIN) |
| +// An rvalue parameter is used because it allows both lvalue and rvalue forms of |
| +// |arg| to be passed as arguments. |
| template <typename TVal> |
| -inline constexpr TVal AnalysisAssumeTrue(TVal arg) { |
| +inline constexpr TVal AnalysisAssumeTrue(TVal&& arg) { |
| __analysis_assume(!!arg); |
| return arg; |
| } |
| @@ -628,16 +632,20 @@ std::string* MakeCheckOpString<std::string, std::string>( |
| // The (int, int) specialization works around the issue that the compiler |
| // will not instantiate the template version of the function on values of |
| // unnamed enum type - see comment below. |
| -#define DEFINE_CHECK_OP_IMPL(name, op) \ |
| - template <class t1, class t2> \ |
| - inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ |
| - const char* names) { \ |
| - if (v1 op v2) return NULL; \ |
| - else return ::logging::MakeCheckOpString(v1, v2, names); \ |
| - } \ |
| +#define DEFINE_CHECK_OP_IMPL(name, op) \ |
| + template <class t1, class t2> \ |
| + inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ |
| + const char* names) { \ |
| + if (ANALYZER_ASSUME_TRUE(v1 op v2)) \ |
|
danakj
2017/02/14 20:09:16
I think this is a separate CL. Can you split this?
Kevin M
2017/02/14 21:05:09
Done.
|
| + return NULL; \ |
| + else \ |
| + return ::logging::MakeCheckOpString(v1, v2, names); \ |
| + } \ |
| inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ |
| - if (v1 op v2) return NULL; \ |
| - else return ::logging::MakeCheckOpString(v1, v2, names); \ |
| + if (ANALYZER_ASSUME_TRUE(v1 op v2)) \ |
| + return NULL; \ |
| + else \ |
| + return ::logging::MakeCheckOpString(v1, v2, names); \ |
| } |
| DEFINE_CHECK_OP_IMPL(EQ, ==) |
| DEFINE_CHECK_OP_IMPL(NE, !=) |