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

Unified Diff: runtime/platform/assert.h

Issue 2470663006: Add .clang-format and run clang-format on runtime/platform. (Closed)
Patch Set: Remove default override for short functions Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/platform/address_sanitizer.h ('k') | runtime/platform/assert.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/platform/assert.h
diff --git a/runtime/platform/assert.h b/runtime/platform/assert.h
index 1d353277d539a410d11fd1ff749aa06d68d4a2a0..02e0e8f3bc3fac6763d66a52c8f2b6295b74a9a5 100644
--- a/runtime/platform/assert.h
+++ b/runtime/platform/assert.h
@@ -26,51 +26,48 @@ namespace dart {
class DynamicAssertionHelper {
public:
- enum Kind {
- ASSERT,
- EXPECT
- };
+ enum Kind { ASSERT, EXPECT };
DynamicAssertionHelper(const char* file, int line, Kind kind)
- : file_(file), line_(line), kind_(kind) { }
+ : file_(file), line_(line), kind_(kind) {}
void Fail(const char* format, ...) PRINTF_ATTRIBUTE(2, 3);
static bool failed() { return failed_; }
#if defined(TESTING)
- template<typename E, typename A>
+ template <typename E, typename A>
void Equals(const E& expected, const A& actual);
- template<typename E, typename A>
+ template <typename E, typename A>
void NotEquals(const E& not_expected, const A& actual);
- template<typename E, typename A, typename T>
+ template <typename E, typename A, typename T>
void FloatEquals(const E& expected, const A& actual, const T& tol);
- template<typename E, typename A>
+ template <typename E, typename A>
void StringEquals(const E& expected, const A& actual);
- template<typename E, typename A>
+ template <typename E, typename A>
void IsSubstring(const E& needle, const A& haystack);
- template<typename E, typename A>
+ template <typename E, typename A>
void IsNotSubstring(const E& needle, const A& haystack);
- template<typename E, typename A>
+ template <typename E, typename A>
void LessThan(const E& left, const A& right);
- template<typename E, typename A>
+ template <typename E, typename A>
void LessEqual(const E& left, const A& right);
- template<typename E, typename A>
+ template <typename E, typename A>
void GreaterThan(const E& left, const A& right);
- template<typename E, typename A>
+ template <typename E, typename A>
void GreaterEqual(const E& left, const A& right);
#endif
- template<typename T>
+ template <typename T>
T NotNull(const T p);
private:
@@ -84,24 +81,24 @@ class DynamicAssertionHelper {
};
-class Assert: public DynamicAssertionHelper {
+class Assert : public DynamicAssertionHelper {
public:
Assert(const char* file, int line)
- : DynamicAssertionHelper(file, line, ASSERT) { }
+ : DynamicAssertionHelper(file, line, ASSERT) {}
};
-class Expect: public DynamicAssertionHelper {
+class Expect : public DynamicAssertionHelper {
public:
Expect(const char* file, int line)
- : DynamicAssertionHelper(file, line, EXPECT) { }
+ : DynamicAssertionHelper(file, line, EXPECT) {}
};
#if defined(TESTING)
// Only allow the expensive (with respect to code size) assertions
// in testing code.
-template<typename E, typename A>
+template <typename E, typename A>
void DynamicAssertionHelper::Equals(const E& expected, const A& actual) {
if (actual == expected) return;
std::ostringstream ess, ass;
@@ -112,9 +109,8 @@ void DynamicAssertionHelper::Equals(const E& expected, const A& actual) {
}
-template<typename E, typename A>
-void DynamicAssertionHelper::NotEquals(const E& not_expected,
- const A& actual) {
+template <typename E, typename A>
+void DynamicAssertionHelper::NotEquals(const E& not_expected, const A& actual) {
if (actual != not_expected) return;
std::ostringstream ness;
ness << not_expected;
@@ -123,7 +119,7 @@ void DynamicAssertionHelper::NotEquals(const E& not_expected,
}
-template<typename E, typename A, typename T>
+template <typename E, typename A, typename T>
void DynamicAssertionHelper::FloatEquals(const E& expected,
const A& actual,
const T& tol) {
@@ -135,16 +131,14 @@ void DynamicAssertionHelper::FloatEquals(const E& expected,
ass << actual;
tolss << tol;
std::string es = ess.str(), as = ass.str(), tols = tolss.str();
- Fail("expected: <%s> but was: <%s> (tolerance: <%s>)",
- es.c_str(),
- as.c_str(),
+ Fail("expected: <%s> but was: <%s> (tolerance: <%s>)", es.c_str(), as.c_str(),
tols.c_str());
}
-template<typename E, typename A>
-NO_SANITIZE_MEMORY
-void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) {
+template <typename E, typename A>
+NO_SANITIZE_MEMORY void DynamicAssertionHelper::StringEquals(const E& expected,
+ const A& actual) {
std::ostringstream ess, ass;
ess << expected;
ass << actual;
@@ -154,34 +148,34 @@ void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) {
}
-template<typename E, typename A>
-NO_SANITIZE_MEMORY
-void DynamicAssertionHelper::IsSubstring(const E& needle, const A& haystack) {
+template <typename E, typename A>
+NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsSubstring(const E& needle,
+ const A& haystack) {
std::ostringstream ess, ass;
ess << needle;
ass << haystack;
std::string es = ess.str(), as = ass.str();
if (as.find(es) != std::string::npos) return;
- Fail("expected <\"%s\"> to be a substring of <\"%s\">",
- es.c_str(), as.c_str());
+ Fail("expected <\"%s\"> to be a substring of <\"%s\">", es.c_str(),
+ as.c_str());
}
-template<typename E, typename A>
-NO_SANITIZE_MEMORY
-void DynamicAssertionHelper::IsNotSubstring(const E& needle,
- const A& haystack) {
+template <typename E, typename A>
+NO_SANITIZE_MEMORY void DynamicAssertionHelper::IsNotSubstring(
+ const E& needle,
+ const A& haystack) {
std::ostringstream ess, ass;
ess << needle;
ass << haystack;
std::string es = ess.str(), as = ass.str();
if (as.find(es) == std::string::npos) return;
- Fail("expected <\"%s\"> to not be a substring of <\"%s\">",
- es.c_str(), as.c_str());
+ Fail("expected <\"%s\"> to not be a substring of <\"%s\">", es.c_str(),
+ as.c_str());
}
-template<typename E, typename A>
+template <typename E, typename A>
void DynamicAssertionHelper::LessThan(const E& left, const A& right) {
if (left < right) return;
std::ostringstream ess, ass;
@@ -192,7 +186,7 @@ void DynamicAssertionHelper::LessThan(const E& left, const A& right) {
}
-template<typename E, typename A>
+template <typename E, typename A>
void DynamicAssertionHelper::LessEqual(const E& left, const A& right) {
if (left <= right) return;
std::ostringstream ess, ass;
@@ -203,7 +197,7 @@ void DynamicAssertionHelper::LessEqual(const E& left, const A& right) {
}
-template<typename E, typename A>
+template <typename E, typename A>
void DynamicAssertionHelper::GreaterThan(const E& left, const A& right) {
if (left > right) return;
std::ostringstream ess, ass;
@@ -214,7 +208,7 @@ void DynamicAssertionHelper::GreaterThan(const E& left, const A& right) {
}
-template<typename E, typename A>
+template <typename E, typename A>
void DynamicAssertionHelper::GreaterEqual(const E& left, const A& right) {
if (left >= right) return;
std::ostringstream ess, ass;
@@ -226,7 +220,7 @@ void DynamicAssertionHelper::GreaterEqual(const E& left, const A& right) {
#endif
-template<typename T>
+template <typename T>
T DynamicAssertionHelper::NotNull(const T p) {
if (p != NULL) return p;
Fail("expected: not NULL, found NULL");
@@ -236,11 +230,9 @@ T DynamicAssertionHelper::NotNull(const T p) {
} // namespace dart
-#define FATAL(error) \
- dart::Assert(__FILE__, __LINE__).Fail("%s", error)
+#define FATAL(error) dart::Assert(__FILE__, __LINE__).Fail("%s", error)
-#define FATAL1(format, p1) \
- dart::Assert(__FILE__, __LINE__).Fail(format, (p1))
+#define FATAL1(format, p1) dart::Assert(__FILE__, __LINE__).Fail(format, (p1))
#define FATAL2(format, p1, p2) \
dart::Assert(__FILE__, __LINE__).Fail(format, (p1), (p2))
@@ -248,14 +240,11 @@ T DynamicAssertionHelper::NotNull(const T p) {
#define FATAL3(format, p1, p2, p3) \
dart::Assert(__FILE__, __LINE__).Fail(format, (p1), (p2), (p3))
-#define UNIMPLEMENTED() \
- FATAL("unimplemented code")
+#define UNIMPLEMENTED() FATAL("unimplemented code")
-#define UNREACHABLE() \
- FATAL("unreachable code")
+#define UNREACHABLE() FATAL("unreachable code")
-#define OUT_OF_MEMORY() \
- FATAL("Out of memory.")
+#define OUT_OF_MEMORY() FATAL("Out of memory.")
#if defined(DEBUG)
@@ -275,15 +264,16 @@ T DynamicAssertionHelper::NotNull(const T p) {
// Returns 'ptr'; useful for initializer lists:
// class Foo { Foo(int* ptr) : ptr_(ASSERT_NOTNULL(ptr)) ...
-#define ASSERT_NOTNULL(ptr) \
- dart::Assert(__FILE__, __LINE__).NotNull((ptr))
+#define ASSERT_NOTNULL(ptr) dart::Assert(__FILE__, __LINE__).NotNull((ptr))
#else // if defined(DEBUG)
// In order to avoid variable unused warnings for code that only uses
// a variable in an ASSERT or EXPECT, we make sure to use the macro
// argument.
-#define ASSERT(condition) do {} while (false && (condition))
+#define ASSERT(condition) \
+ do { \
+ } while (false && (condition))
#define DEBUG_ASSERT(cond)
@@ -310,8 +300,7 @@ T DynamicAssertionHelper::NotNull(const T p) {
//
template <bool>
-struct CompileAssert {
-};
+struct CompileAssert {};
// Macro to concatenate two tokens. The helper is need to proper expansion
// in case an argument is a macro itself.
#if !defined(COMPILE_ASSERT)
@@ -319,8 +308,8 @@ struct CompileAssert {
#define COMPILE_ASSERT_JOIN_HELPER(a, b) a##b
#define COMPILE_ASSERT(expr) \
DART_UNUSED typedef CompileAssert<(static_cast<bool>(expr))> \
- COMPILE_ASSERT_JOIN(CompileAssertTypeDef, __LINE__)[static_cast<bool>(expr) \
- ? 1 : -1]
+ COMPILE_ASSERT_JOIN(CompileAssertTypeDef, \
+ __LINE__)[static_cast<bool>(expr) ? 1 : -1]
#endif // !defined(COMPILE_ASSERT)
#if defined(TESTING)
@@ -365,14 +354,11 @@ struct CompileAssert {
#define EXPECT_GE(left, right) \
dart::Expect(__FILE__, __LINE__).GreaterEqual((left), (right))
-#define EXPECT_NOTNULL(ptr) \
- dart::Expect(__FILE__, __LINE__).NotNull((ptr))
+#define EXPECT_NOTNULL(ptr) dart::Expect(__FILE__, __LINE__).NotNull((ptr))
-#define FAIL(error) \
- dart::Expect(__FILE__, __LINE__).Fail("%s", error)
+#define FAIL(error) dart::Expect(__FILE__, __LINE__).Fail("%s", error)
-#define FAIL1(format, p1) \
- dart::Expect(__FILE__, __LINE__).Fail(format, (p1))
+#define FAIL1(format, p1) dart::Expect(__FILE__, __LINE__).Fail(format, (p1))
#define FAIL2(format, p1, p2) \
dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2))
« no previous file with comments | « runtime/platform/address_sanitizer.h ('k') | runtime/platform/assert.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698