sylvestre.ledru updated this revision to Diff 89022.

https://reviews.llvm.org/D30111

Files:
  test/Format/check-coding-style-mozilla.cpp

Index: test/Format/check-coding-style-mozilla.cpp
===================================================================
--- test/Format/check-coding-style-mozilla.cpp
+++ test/Format/check-coding-style-mozilla.cpp
@@ -0,0 +1,130 @@
+// RUN: clang-format -style=Mozilla %s > %T/foo.cpp 2>&1
+// RUN: diff -u %s %T/foo.cpp
+// RUN: rm -rf %T/foo.cpp
+
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+if (true) {
+} else if (false) {
+} else {
+}
+
+while (true) {
+}
+
+do {
+} while (true);
+
+for (auto bar::in) {
+}
+
+switch (var) {
+  case 1: {
+    // When you need to declare a variable in a switch, put the block in braces
+    int var;
+    break;
+  }
+  case 2:
+    foo();
+    break;
+  default:
+    break;
+}
+
+namespace mozilla {
+
+class MyClass : public A
+{
+  void Myclass();
+};
+
+class MyClass : public X // When deriving from more than one class, put each on
+                         // its own line.
+                ,
+                public Y
+{
+public:
+  MyClass(int aVar, int aVar2)
+    : mVar(aVar)
+    , mVar2(aVar2)
+  {
+    foo();
+  }
+
+  // Tiny constructors and destructors can be written on a single line.
+  MyClass() {}
+
+  // Unless it's a copy or move constructor or you have a specific reason to
+  // allow implicit conversions, mark all single-argument constructors explicit.
+  explicit MyClass(OtherClass aArg) { bar(); }
+
+  // This constructor can also take a single argument, so it also needs to be
+  // marked explicit.
+  explicit MyClass(OtherClass aArg, AnotherClass aArg2 = AnotherClass())
+  {
+    foo();
+  }
+
+  int TinyFunction()
+  {
+    return mVar;
+  } // Tiny functions can be written in a single line.
+
+  int LargerFunction()
+  {
+    bar();
+    foo();
+  }
+
+private:
+  int mVar;
+};
+
+} // namespace mozilla
+
+template<typename T> // Templates on own line.
+static int
+MyFunction(int a) // Return type on own line for top-level functions.
+{
+  foo();
+}
+
+int
+MyClass::Method(long b)
+{
+  bar();
+}
+
+T* p; // Correct declaration style
+
+// Test the && and || with parentheses
+return (nextKeyframe < aTimeThreshold ||
+        (mVideo.mTimeThreshold &&
+         mVideo.mTimeThreshold.ref().EndTime() < aTimeThreshold)) &&
+       nextKeyframe.ToMicroseconds() >= 0 && !nextKeyframe.IsInfinite();
+
+// The ? should be placed 2 spaces after the previous declaration
+LOGV("%d audio samples demuxed (sid:%d)",
+     aSamples->mSamples.Length(),
+     aSamples->mSamples[0]->mTrackInfo
+       ? aSamples->mSamples[0]->mTrackInfo->GetID()
+       : 0);
+
+// Test with the 80 chars limit
+return (aDecoder.HasPromise() || aDecoder.mTimeThreshold.isSome()) &&
+       !aDecoder.HasPendingDrain() && !aDecoder.HasFatalError() &&
+       !aDecoder.mDemuxRequest.Exists() && !aDecoder.mOutput.Length() &&
+       !aDecoder.HasInternalSeekPending() && !aDecoder.mDecodeRequest.Exists();
+
+template<int>
+void
+foo();
+
+#define MACRO(V)                                                               \
+  V(Rt2) /* one more char */                                                   \
+  V(Rs)  /* than here  */                                                      \
+/* comment 3 */
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to