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

Side by Side Diff: base/logging.h

Issue 2691243004: Add ANALYSIS_ASSUME_TRUE annotations to DCHECK_OP impl bodies. (Closed)
Patch Set: Created 3 years, 10 months 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 | « no previous file | 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 610 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 std::string* MakeCheckOpString<unsigned int, unsigned long>( 621 std::string* MakeCheckOpString<unsigned int, unsigned long>(
622 const unsigned int&, const unsigned long&, const char* names); 622 const unsigned int&, const unsigned long&, const char* names);
623 extern template BASE_EXPORT 623 extern template BASE_EXPORT
624 std::string* MakeCheckOpString<std::string, std::string>( 624 std::string* MakeCheckOpString<std::string, std::string>(
625 const std::string&, const std::string&, const char* name); 625 const std::string&, const std::string&, const char* name);
626 626
627 // Helper functions for CHECK_OP macro. 627 // Helper functions for CHECK_OP macro.
628 // The (int, int) specialization works around the issue that the compiler 628 // The (int, int) specialization works around the issue that the compiler
629 // will not instantiate the template version of the function on values of 629 // will not instantiate the template version of the function on values of
630 // unnamed enum type - see comment below. 630 // unnamed enum type - see comment below.
631 #define DEFINE_CHECK_OP_IMPL(name, op) \ 631 #define DEFINE_CHECK_OP_IMPL(name, op) \
632 template <class t1, class t2> \ 632 template <class t1, class t2> \
633 inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \ 633 inline std::string* Check##name##Impl(const t1& v1, const t2& v2, \
634 const char* names) { \ 634 const char* names) { \
635 if (v1 op v2) return NULL; \ 635 if (ANALYZER_ASSUME_TRUE(v1 op v2)) \
636 else return ::logging::MakeCheckOpString(v1, v2, names); \ 636 return NULL; \
637 } \ 637 else \
638 return ::logging::MakeCheckOpString(v1, v2, names); \
639 } \
638 inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \ 640 inline std::string* Check##name##Impl(int v1, int v2, const char* names) { \
639 if (v1 op v2) return NULL; \ 641 if (ANALYZER_ASSUME_TRUE(v1 op v2)) \
640 else return ::logging::MakeCheckOpString(v1, v2, names); \ 642 return NULL; \
643 else \
644 return ::logging::MakeCheckOpString(v1, v2, names); \
641 } 645 }
642 DEFINE_CHECK_OP_IMPL(EQ, ==) 646 DEFINE_CHECK_OP_IMPL(EQ, ==)
643 DEFINE_CHECK_OP_IMPL(NE, !=) 647 DEFINE_CHECK_OP_IMPL(NE, !=)
644 DEFINE_CHECK_OP_IMPL(LE, <=) 648 DEFINE_CHECK_OP_IMPL(LE, <=)
645 DEFINE_CHECK_OP_IMPL(LT, < ) 649 DEFINE_CHECK_OP_IMPL(LT, < )
646 DEFINE_CHECK_OP_IMPL(GE, >=) 650 DEFINE_CHECK_OP_IMPL(GE, >=)
647 DEFINE_CHECK_OP_IMPL(GT, > ) 651 DEFINE_CHECK_OP_IMPL(GT, > )
648 #undef DEFINE_CHECK_OP_IMPL 652 #undef DEFINE_CHECK_OP_IMPL
649 653
650 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2) 654 #define CHECK_EQ(val1, val2) CHECK_OP(EQ, ==, val1, val2)
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 #elif NOTIMPLEMENTED_POLICY == 5 1055 #elif NOTIMPLEMENTED_POLICY == 5
1052 #define NOTIMPLEMENTED() do {\ 1056 #define NOTIMPLEMENTED() do {\
1053 static bool logged_once = false;\ 1057 static bool logged_once = false;\
1054 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\ 1058 LOG_IF(ERROR, !logged_once) << NOTIMPLEMENTED_MSG;\
1055 logged_once = true;\ 1059 logged_once = true;\
1056 } while(0);\ 1060 } while(0);\
1057 EAT_STREAM_PARAMETERS 1061 EAT_STREAM_PARAMETERS
1058 #endif 1062 #endif
1059 1063
1060 #endif // BASE_LOGGING_H_ 1064 #endif // BASE_LOGGING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698