Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_LOGGING_H_ | 5 #ifndef BASE_LOGGING_H_ |
| 6 #define BASE_LOGGING_H_ | 6 #define BASE_LOGGING_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <cassert> | 10 #include <cassert> |
| 11 #include <cstring> | 11 #include <cstring> |
| 12 #include <memory> | |
|
danakj
2017/02/14 22:39:31
forward is in <utility> tho
Kevin M
2017/02/14 22:41:01
Done.
| |
| 12 #include <sstream> | 13 #include <sstream> |
| 13 #include <string> | 14 #include <string> |
| 14 #include <type_traits> | 15 #include <type_traits> |
| 15 #include <utility> | 16 #include <utility> |
| 16 | 17 |
| 17 #include "base/base_export.h" | 18 #include "base/base_export.h" |
| 18 #include "base/compiler_specific.h" | 19 #include "base/compiler_specific.h" |
| 19 #include "base/debug/debugger.h" | 20 #include "base/debug/debugger.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 21 #include "base/template_util.h" | 22 #include "base/template_util.h" |
| (...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 | 292 |
| 292 // ANALYZER_ASSUME_TRUE(...) generates compiler-specific annotations which | 293 // ANALYZER_ASSUME_TRUE(...) generates compiler-specific annotations which |
| 293 // prevent the static analyzer from analyzing the code using hypothetical | 294 // prevent the static analyzer from analyzing the code using hypothetical |
| 294 // values that are asserted to be impossible. | 295 // values that are asserted to be impossible. |
| 295 // The value of the condition passed to ANALYZER_ASSUME_TRUE() is returned | 296 // The value of the condition passed to ANALYZER_ASSUME_TRUE() is returned |
| 296 // directly. | 297 // directly. |
| 297 #if defined(__clang_analyzer__) | 298 #if defined(__clang_analyzer__) |
| 298 | 299 |
| 299 inline void AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {} | 300 inline void AnalyzerNoReturn() __attribute__((analyzer_noreturn)) {} |
| 300 | 301 |
| 302 // |arg| is a universal reference for compatibility with lvalue and rvalue | |
| 303 // arguments. | |
| 301 template <typename TVal> | 304 template <typename TVal> |
| 302 inline constexpr TVal AnalysisAssumeTrue(TVal arg) { | 305 inline constexpr TVal&& AnalysisAssumeTrue(TVal&& arg) { |
| 303 if (!arg) { | 306 if (!arg) { |
| 304 AnalyzerNoReturn(); | 307 AnalyzerNoReturn(); |
| 305 } | 308 } |
| 306 return arg; | 309 return std::forward<TVal>(arg); |
| 307 } | 310 } |
| 308 | 311 |
| 309 #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) | 312 #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) |
| 310 | 313 |
| 311 #elif defined(_PREFAST_) && defined(OS_WIN) | 314 #elif defined(_PREFAST_) && defined(OS_WIN) |
| 312 | 315 |
| 316 // |arg| is a universal reference for compatibility with lvalue and rvalue | |
| 317 // arguments. | |
| 313 template <typename TVal> | 318 template <typename TVal> |
| 314 inline constexpr TVal AnalysisAssumeTrue(TVal arg) { | 319 inline constexpr TVal&& AnalysisAssumeTrue(TVal&& arg) { |
| 315 __analysis_assume(!!arg); | 320 __analysis_assume(!!arg); |
| 316 return arg; | 321 return std::forward<TVal>(arg); |
| 317 } | 322 } |
| 318 | 323 |
| 319 #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) | 324 #define ANALYZER_ASSUME_TRUE(val) ::logging::AnalysisAssumeTrue(val) |
| 320 | 325 |
| 321 #else // !_PREFAST_ & !__clang_analyzer__ | 326 #else // !_PREFAST_ & !__clang_analyzer__ |
| 322 | 327 |
| 323 #define ANALYZER_ASSUME_TRUE(val) (val) | 328 #define ANALYZER_ASSUME_TRUE(val) (val) |
| 324 | 329 |
| 325 #endif // !_PREFAST_ & !__clang_analyzer__ | 330 #endif // !_PREFAST_ & !__clang_analyzer__ |
| 326 | 331 |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 #elif NOTIMPLEMENTED_POLICY == 5 | 1056 #elif NOTIMPLEMENTED_POLICY == 5 |
| 1052 #define NOTIMPLEMENTED() do {\ | 1057 #define NOTIMPLEMENTED() do {\ |
| 1053 static bool logged_once = false;\ | 1058 static bool logged_once = false;\ |
| 1054 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ | 1059 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ |
| 1055 logged_once = true;\ | 1060 logged_once = true;\ |
| 1056 } while(0);\ | 1061 } while(0);\ |
| 1057 EAT_STREAM_PARAMETERS | 1062 EAT_STREAM_PARAMETERS |
| 1058 #endif | 1063 #endif |
| 1059 | 1064 |
| 1060 #endif // BASE_LOGGING_H_ | 1065 #endif // BASE_LOGGING_H_ |
| OLD | NEW |