| OLD | NEW |
| 1 // Copyright 2014 The Crashpad Authors. All rights reserved. | 1 // Copyright 2014 The Crashpad Authors. All rights reserved. |
| 2 // | 2 // |
| 3 // Licensed under the Apache License, Version 2.0 (the "License"); | 3 // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 // you may not use this file except in compliance with the License. | 4 // you may not use this file except in compliance with the License. |
| 5 // You may obtain a copy of the License at | 5 // You may obtain a copy of the License at |
| 6 // | 6 // |
| 7 // http://www.apache.org/licenses/LICENSE-2.0 | 7 // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 // | 8 // |
| 9 // Unless required by applicable law or agreed to in writing, software | 9 // Unless required by applicable law or agreed to in writing, software |
| 10 // distributed under the License is distributed on an "AS IS" BASIS, | 10 // distributed under the License is distributed on an "AS IS" BASIS, |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 #else | 155 #else |
| 156 | 156 |
| 157 // Since this is to be used as a DCHECK (for debugging), it should be | 157 // Since this is to be used as a DCHECK (for debugging), it should be |
| 158 // non-intrusive in non-DCHECK (non-debug, release) builds. An empty struct | 158 // non-intrusive in non-DCHECK (non-debug, release) builds. An empty struct |
| 159 // would still have a nonzero size (rationale: | 159 // would still have a nonzero size (rationale: |
| 160 // http://www.stroustrup.com/bs_faq2.html#sizeof-empty). Zero-length arrays are | 160 // http://www.stroustrup.com/bs_faq2.html#sizeof-empty). Zero-length arrays are |
| 161 // technically invalid according to the standard, but clang and g++ accept them | 161 // technically invalid according to the standard, but clang and g++ accept them |
| 162 // without complaint even with warnings turned up. They take up no space at all, | 162 // without complaint even with warnings turned up. They take up no space at all, |
| 163 // and they can be “initialized” with the same () syntax used to initialize | 163 // and they can be “initialized” with the same () syntax used to initialize |
| 164 // objects of the DCHECK_IS_ON InitializationStateDcheck class above. | 164 // objects of the DCHECK_IS_ON InitializationStateDcheck class above. |
| 165 typedef bool InitializationStateDcheck[0]; | 165 using InitializationStateDcheck = bool[0]; |
| 166 | 166 |
| 167 namespace internal { | 167 namespace internal { |
| 168 | 168 |
| 169 // This function exists to make use of the InitializationStateDcheck object so | 169 // This function exists to make use of the InitializationStateDcheck object so |
| 170 // that it appears to be used. It always returns true, so that it can be used | 170 // that it appears to be used. It always returns true, so that it can be used |
| 171 // as the argument to a no-op DCHECK. | 171 // as the argument to a no-op DCHECK. |
| 172 inline bool EatInitializationState(const InitializationStateDcheck*) { | 172 inline bool EatInitializationState(const InitializationStateDcheck*) { |
| 173 return true; | 173 return true; |
| 174 } | 174 } |
| 175 | 175 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 186 &(initialization_state_dcheck))) | 186 &(initialization_state_dcheck))) |
| 187 #define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \ | 187 #define INITIALIZATION_STATE_DCHECK_VALID(initialization_state_dcheck) \ |
| 188 DCHECK(::crashpad::internal::EatInitializationState( \ | 188 DCHECK(::crashpad::internal::EatInitializationState( \ |
| 189 &(initialization_state_dcheck))) | 189 &(initialization_state_dcheck))) |
| 190 | 190 |
| 191 #endif | 191 #endif |
| 192 | 192 |
| 193 } // namespace crashpad | 193 } // namespace crashpad |
| 194 | 194 |
| 195 #endif // CRASHPAD_UTIL_MISC_INITIALIZATION_INITIALIZATION_STATE_DCHECK_H_ | 195 #endif // CRASHPAD_UTIL_MISC_INITIALIZATION_INITIALIZATION_STATE_DCHECK_H_ |
| OLD | NEW |