From: Igor Sugak <sugak@fb.com>
Date: Wed, 13 May 2015 06:40:34 +0000 (-0700)
Subject: folly: fix mismatched-tags
X-Git-Tag: v0.39.0~20
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ec66459bbd15d255a5e2d9062c63a49f251103f0;p=folly.git

folly: fix mismatched-tags

Summary:
I tried to fix this for default glibc but there are many mismatched-tags inside glibc itself. gcc-4.9-glibc-2.20 does not have such issue, using it.

```lang=bash
% fbconfig --clang --with-project-version clang:dev --extra-cxxflags=-Wmismatched-tags --extra-cxxflags=-ferror-limit=0 --platform-all=gcc-4.9-glibc-2.20-fb -r folly
% fbmake dev -j55 2> err
% perl -n -E 'm/\[-Werror,-Wmismatched-tags\]$/ && print' err | sort -u
./folly/experimental/fibers/TimeoutController.h:52:3: error: 'TimeoutHandle' defined as a struct here but previously declared as a class [-Werror,-Wmismatched-tags]
folly/experimental/fibers/TimeoutController.h:52:3: error: 'TimeoutHandle' defined as a struct here but previously declared as a class [-Werror,-Wmismatched-tags]
folly/experimental/JSONSchema.cpp:65:10: error: class 'ValidationContext' was previously declared as a struct [-Werror,-Wmismatched-tags]
./folly/futures/detail/Core.h:76:1: error: 'Core' defined as a class template here but previously declared as a struct template [-Werror,-Wmismatched-tags]
./folly/futures/Future.h:392:10: error: class 'Promise' was previously declared as a struct [-Werror,-Wmismatched-tags]
./folly/futures/Future.h:45:1: error: 'Future' defined as a class template here but previously declared as a struct template [-Werror,-Wmismatched-tags]
./folly/futures/Future-pre.h:137:1: error: struct 'Timekeeper' was previously declared as a class [-Werror,-Wmismatched-tags]
./folly/futures/Future-pre.h:23:18: error: struct template 'Promise' was previously declared as a class template [-Werror,-Wmismatched-tags]
./folly/futures/Future-pre.h:43:18: error: struct template 'Core' was previously declared as a class template [-Werror,-Wmismatched-tags]
./folly/futures/Promise.h:26:20: error: class template 'Future' was previously declared as a struct template [-Werror,-Wmismatched-tags]
./folly/futures/Timekeeper.h:23:18: error: struct template 'Future' was previously declared as a class template [-Werror,-Wmismatched-tags]
./folly/futures/Timekeeper.h:44:1: error: 'Timekeeper' defined as a class here but previously declared as a struct [-Werror,-Wmismatched-tags]
./folly/Singleton.h:378:10: error: class template 'SingletonHolder' was previously declared as a struct template [-Werror,-Wmismatched-tags]
./folly/wangle/ssl/SSLCacheOptions.h:17:1: error: 'SSLCacheOptions' defined as a struct here but previously declared as a class [-Werror,-Wmismatched-tags]
./folly/wangle/ssl/SSLContextManager.h:29:1: error: class 'SSLCacheOptions' was previously declared as a struct [-Werror,-Wmismatched-tags]
./folly/wangle/ssl/SSLContextManager.h:32:1: error: class 'TLSTicketKeySeeds' was previously declared as a struct [-Werror,-Wmismatched-tags]
% perl -n -E 'm/\[-Werror,-Wmismatched-tags\]$/ && print' err | sort -u | wc -l
16
```

Updated manually. In all cases preferred tag from definition.

Test Plan:
Compile with clang dev and gcc-4.9-glibc-2.20-fb and see fewer errors:
```lang=bash
% fbconfig --clang --with-project-version clang:dev --extra-cxxflags=-Wmismatched-tags --platform-all=gcc-4.9-glibc-2.20-fb -r folly
% fbmake dev -j55
```

Reviewed By: markisaa@fb.com, meyering@fb.com

Subscribers: fugalh, folly-diffs@, jsedgwick, yfeldblum, chalfant

FB internal diff: D2066327

Signature: t1:2066327:1431471232:c65c2827398ba29a4022cc6a5647fac2b3aad717
---

diff --git a/folly/Singleton.h b/folly/Singleton.h
index c9868d4d..4a33205c 100644
--- a/folly/Singleton.h
+++ b/folly/Singleton.h
@@ -375,7 +375,7 @@ class SingletonVault {
 
  private:
   template <typename T>
-  friend class detail::SingletonHolder;
+  friend struct detail::SingletonHolder;
 
   // The two stages of life for a vault, as mentioned in the class comment.
   enum class SingletonVaultState {
diff --git a/folly/experimental/JSONSchema.cpp b/folly/experimental/JSONSchema.cpp
index 5413da38..5297c28e 100644
--- a/folly/experimental/JSONSchema.cpp
+++ b/folly/experimental/JSONSchema.cpp
@@ -62,7 +62,7 @@ struct IValidator {
   virtual ~IValidator() {}
 
  private:
-  friend class ValidationContext;
+  friend struct ValidationContext;
 
   virtual Optional<SchemaError> validate(ValidationContext&,
                                          const dynamic& value) const = 0;
diff --git a/folly/experimental/fibers/TimeoutController.h b/folly/experimental/fibers/TimeoutController.h
index f74faeb5..cd3ce25f 100644
--- a/folly/experimental/fibers/TimeoutController.h
+++ b/folly/experimental/fibers/TimeoutController.h
@@ -45,7 +45,7 @@ class TimeoutController :
  private:
   void scheduleRun();
 
-  class TimeoutHandle;
+  struct TimeoutHandle;
   typedef std::queue<TimeoutHandle> TimeoutHandleList;
   typedef std::unique_ptr<TimeoutHandleList> TimeoutHandleListPtr;
 
diff --git a/folly/futures/Future-pre.h b/folly/futures/Future-pre.h
index 70add42a..b7ee7b5c 100644
--- a/folly/futures/Future-pre.h
+++ b/folly/futures/Future-pre.h
@@ -20,7 +20,7 @@
 
 namespace folly {
 
-template <class> struct Promise;
+template <class> class Promise;
 
 template <typename T>
 struct isFuture : std::false_type {
@@ -40,7 +40,7 @@ struct isTry<Try<T>> : std::true_type {};
 
 namespace detail {
 
-template <class> struct Core;
+template <class> class Core;
 template <class...> struct VariadicContext;
 template <class> struct CollectContext;
 
@@ -134,6 +134,6 @@ struct Extract<R(Class::*)(Args...)> {
 } // detail
 
 
-struct Timekeeper;
+class Timekeeper;
 
 } // namespace
diff --git a/folly/futures/Timekeeper.h b/folly/futures/Timekeeper.h
index b9019f28..3612f5cf 100644
--- a/folly/futures/Timekeeper.h
+++ b/folly/futures/Timekeeper.h
@@ -20,7 +20,7 @@
 
 namespace folly {
 
-template <class> struct Future;
+template <class> class Future;
 
 /// A Timekeeper handles the details of keeping time and fulfilling delay
 /// promises. The returned Future<void> will either complete after the
diff --git a/folly/wangle/ssl/SSLContextManager.h b/folly/wangle/ssl/SSLContextManager.h
index 01364f02..5877f1d4 100644
--- a/folly/wangle/ssl/SSLContextManager.h
+++ b/folly/wangle/ssl/SSLContextManager.h
@@ -26,10 +26,10 @@ namespace folly {
 class SocketAddress;
 class SSLContext;
 class ClientHelloExtStats;
-class SSLCacheOptions;
+struct SSLCacheOptions;
 class SSLStats;
 class TLSTicketKeyManager;
-class TLSTicketKeySeeds;
+struct TLSTicketKeySeeds;
 
 class SSLContextManager {
  public: