Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: base/logging.h

Issue 2569583002: Revert of Improve EAT_STREAM_PARAMETERS for Windows x86 (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/check_example.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
419 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \ 419 COMPACT_GOOGLE_LOG_EX_ ## severity(ErrnoLogMessage, \
420 ::logging::GetLastSystemErrorCode()).stream() 420 ::logging::GetLastSystemErrorCode()).stream()
421 #endif 421 #endif
422 422
423 #define PLOG(severity) \ 423 #define PLOG(severity) \
424 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity)) 424 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity))
425 425
426 #define PLOG_IF(severity, condition) \ 426 #define PLOG_IF(severity, condition) \
427 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition)) 427 LAZY_STREAM(PLOG_STREAM(severity), LOG_IS_ON(severity) && (condition))
428 428
429 // Note that the null ostream is used instead of an arbitrary LOG() stream to 429 // The actual stream used isn't important.
430 // avoid the creation of an object with a non-trivial destructor (LogMessage). 430 #define EAT_STREAM_PARAMETERS \
431 // On MSVC x86 (checked on 2015 Update 3), doing so causes a few additional 431 true ? (void) 0 : ::logging::LogMessageVoidify() & LOG_STREAM(FATAL)
432 // pointless instructions to be emitted even at full optimization level, even
433 // though the : arm of the ternary operator is clearly never executed. Using a
434 // simpler POD object with a templated operator<< also works to avoid these
435 // instructions. However, this causes warnings on statically defined
436 // implementations of operator<<(std::ostream, ...) in some .cc files, because
437 // they become defined-but-unreferenced functions.
438 #define EAT_STREAM_PARAMETERS \
439 true \
440 ? (void)0 \
441 : ::logging::LogMessageVoidify() & (*reinterpret_cast<std::ostream*>(0))
442 432
443 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a 433 // Captures the result of a CHECK_EQ (for example) and facilitates testing as a
444 // boolean. 434 // boolean.
445 class CheckOpResult { 435 class CheckOpResult {
446 public: 436 public:
447 // |message| must be non-null if and only if the check failed. 437 // |message| must be non-null if and only if the check failed.
448 CheckOpResult(std::string* message) : message_(message) {} 438 CheckOpResult(std::string* message) : message_(message) {}
449 // Returns true if the check succeeded. 439 // Returns true if the check succeeded.
450 operator bool() const { return !message_; } 440 operator bool() const { return !message_; }
451 // Returns the message. 441 // Returns the message.
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 #elif NOTIMPLEMENTED_POLICY == 5 1015 #elif NOTIMPLEMENTED_POLICY == 5
1026 #define NOTIMPLEMENTED() do {\ 1016 #define NOTIMPLEMENTED() do {\
1027 static bool logged_once = false;\ 1017 static bool logged_once = false;\
1028 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1018 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1029 logged_once = true;\ 1019 logged_once = true;\
1030 } while(0);\ 1020 } while(0);\
1031 EAT_STREAM_PARAMETERS 1021 EAT_STREAM_PARAMETERS
1032 #endif 1022 #endif
1033 1023
1034 #endif // BASE_LOGGING_H_ 1024 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « base/check_example.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698