Enable MSVS warning 4512.

Fix up the missing DISALLOW_COPY_AND_ASSIGN macros and various small
problems preventing us from turning on this warning. This should
ensure we more often use the DISALLOW macro going forward.

Change-Id: I2e1a9d23a31a51279a577fad8dffb8c1530e2ee8
Reviewed-on: https://chromium-review.googlesource.com/251100
Tested-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Cooper Partin <coopp@microsoft.com>
Tested-by: Cooper Partin <coopp@microsoft.com>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/translator/Diagnostics.h b/src/compiler/translator/Diagnostics.h
index 4173e36..06608c1 100644
--- a/src/compiler/translator/Diagnostics.h
+++ b/src/compiler/translator/Diagnostics.h
@@ -7,6 +7,7 @@
 #ifndef COMPILER_TRANSLATOR_DIAGNOSTICS_H_
 #define COMPILER_TRANSLATOR_DIAGNOSTICS_H_
 
+#include "common/angleutils.h"
 #include "compiler/preprocessor/DiagnosticsBase.h"
 
 class TInfoSink;
@@ -36,6 +37,8 @@
                        const std::string& text);
 
   private:
+    DISALLOW_COPY_AND_ASSIGN(TDiagnostics);
+
     TInfoSink& mInfoSink;
     int mNumErrors;
     int mNumWarnings;
diff --git a/src/compiler/translator/DirectiveHandler.h b/src/compiler/translator/DirectiveHandler.h
index 70f6665..f7b34da 100644
--- a/src/compiler/translator/DirectiveHandler.h
+++ b/src/compiler/translator/DirectiveHandler.h
@@ -7,6 +7,7 @@
 #ifndef COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
 #define COMPILER_TRANSLATOR_DIRECTIVEHANDLER_H_
 
+#include "common/angleutils.h"
 #include "compiler/translator/ExtensionBehavior.h"
 #include "compiler/translator/Pragma.h"
 #include "compiler/preprocessor/DirectiveHandlerBase.h"
@@ -41,6 +42,8 @@
                                int version);
 
   private:
+    DISALLOW_COPY_AND_ASSIGN(TDirectiveHandler);
+
     TPragma mPragma;
     TExtensionBehavior& mExtensionBehavior;
     TDiagnostics& mDiagnostics;
diff --git a/src/compiler/translator/IntermNode.h b/src/compiler/translator/IntermNode.h
index 2d52900..3ea3691 100644
--- a/src/compiler/translator/IntermNode.h
+++ b/src/compiler/translator/IntermNode.h
@@ -21,6 +21,7 @@
 #include <algorithm>
 #include <queue>
 
+#include "common/angleutils.h"
 #include "compiler/translator/Common.h"
 #include "compiler/translator/Types.h"
 #include "compiler/translator/ConstantUnion.h"
@@ -589,6 +590,9 @@
     // During traversing, save all the changes that need to happen into
     // mReplacements, then do them by calling updateTree().
     std::vector<NodeUpdateEntry> mReplacements;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TIntermTraverser);
 };
 
 //
@@ -610,10 +614,13 @@
     virtual bool visitLoop(Visit, TIntermLoop *) { return depthCheck(); }
     virtual bool visitBranch(Visit, TIntermBranch *) { return depthCheck(); }
 
-protected:
+  protected:
     bool depthCheck() const { return mMaxDepth < mDepthLimit; }
 
     int mDepthLimit;
+
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TMaxDepthTraverser);
 };
 
 #endif  // COMPILER_TRANSLATOR_INTERMNODE_H_
diff --git a/src/compiler/translator/StructureHLSL.cpp b/src/compiler/translator/StructureHLSL.cpp
index 304949b..fd1a29c 100644
--- a/src/compiler/translator/StructureHLSL.cpp
+++ b/src/compiler/translator/StructureHLSL.cpp
@@ -21,9 +21,23 @@
                                          unsigned *uniqueCounter)
     : mPaddingCounter(uniqueCounter),
       mElementIndex(0),
-      mStructElementIndexes(structElementIndexes)
+      mStructElementIndexes(&structElementIndexes)
 {}
 
+Std140PaddingHelper::Std140PaddingHelper(const Std140PaddingHelper &other)
+    : mPaddingCounter(other.mPaddingCounter),
+      mElementIndex(other.mElementIndex),
+      mStructElementIndexes(other.mStructElementIndexes)
+{}
+
+Std140PaddingHelper &Std140PaddingHelper::operator=(const Std140PaddingHelper &other)
+{
+    mPaddingCounter = other.mPaddingCounter;
+    mElementIndex = other.mElementIndex;
+    mStructElementIndexes = other.mStructElementIndexes;
+    return *this;
+}
+
 TString Std140PaddingHelper::next()
 {
     unsigned value = (*mPaddingCounter)++;
@@ -107,7 +121,7 @@
     {
         const TString &structName = QualifiedStructNameString(*structure,
                                                               useHLSLRowMajorPacking, true);
-        numComponents = mStructElementIndexes.find(structName)->second;
+        numComponents = mStructElementIndexes->find(structName)->second;
 
         if (numComponents == 0)
         {
diff --git a/src/compiler/translator/StructureHLSL.h b/src/compiler/translator/StructureHLSL.h
index 3bf7003..c62150a 100644
--- a/src/compiler/translator/StructureHLSL.h
+++ b/src/compiler/translator/StructureHLSL.h
@@ -27,7 +27,9 @@
 {
   public:
     explicit Std140PaddingHelper(const std::map<TString, int> &structElementIndexes,
-                                 unsigned *uniqueCounter);
+                                 unsigned int *uniqueCounter);
+    Std140PaddingHelper(const Std140PaddingHelper &other);
+    Std140PaddingHelper &operator=(const Std140PaddingHelper &other);
 
     int elementIndex() const { return mElementIndex; }
     int prePadding(const TType &type);
@@ -39,7 +41,7 @@
 
     unsigned *mPaddingCounter;
     int mElementIndex;
-    const std::map<TString, int> &mStructElementIndexes;
+    const std::map<TString, int> *mStructElementIndexes;
 };
 
 class StructureHLSL
@@ -56,6 +58,8 @@
     Std140PaddingHelper getPaddingHelper();
 
   private:
+    DISALLOW_COPY_AND_ASSIGN(StructureHLSL);
+
     unsigned mUniquePaddingCounter;
 
     std::map<TString, int> mStd140StructElementIndexes;
diff --git a/src/compiler/translator/UniformHLSL.h b/src/compiler/translator/UniformHLSL.h
index 1d875c1..3032df3 100644
--- a/src/compiler/translator/UniformHLSL.h
+++ b/src/compiler/translator/UniformHLSL.h
@@ -39,6 +39,8 @@
     }
 
   private:
+    DISALLOW_COPY_AND_ASSIGN(UniformHLSL);
+
     TString interfaceBlockString(const TInterfaceBlock &interfaceBlock, unsigned int registerIndex, unsigned int arrayIndex);
     TString interfaceBlockMembersString(const TInterfaceBlock &interfaceBlock, TLayoutBlockStorage blockStorage);
     TString interfaceBlockStructString(const TInterfaceBlock &interfaceBlock);
diff --git a/src/compiler/translator/VariableInfo.h b/src/compiler/translator/VariableInfo.h
index bb1328a..6b752ad 100644
--- a/src/compiler/translator/VariableInfo.h
+++ b/src/compiler/translator/VariableInfo.h
@@ -33,6 +33,8 @@
     virtual bool visitBinary(Visit visit, TIntermBinary *binaryNode);
 
   private:
+    DISALLOW_COPY_AND_ASSIGN(CollectVariables);
+
     template <typename VarT>
     void visitVariable(const TIntermSymbol *variable, std::vector<VarT> *infoList) const;
 
diff --git a/src/compiler/translator/depgraph/DependencyGraphBuilder.h b/src/compiler/translator/depgraph/DependencyGraphBuilder.h
index 2a2fa73..16a3738 100644
--- a/src/compiler/translator/depgraph/DependencyGraphBuilder.h
+++ b/src/compiler/translator/depgraph/DependencyGraphBuilder.h
@@ -115,6 +115,9 @@
         ~TNodeSetMaintainer() { mSets.popSet(); }
       protected:
         TNodeSetStack &mSets;
+
+      private:
+        DISALLOW_COPY_AND_ASSIGN(TNodeSetMaintainer);
     };
 
     //
@@ -133,6 +136,8 @@
         ~TNodeSetPropagatingMaintainer() { mSets.popSetIntoNext(); }
       protected:
         TNodeSetStack &mSets;
+      private:
+        DISALLOW_COPY_AND_ASSIGN(TNodeSetPropagatingMaintainer);
     };
 
     //
@@ -169,6 +174,8 @@
       protected:
         TSymbolStack& mLeftmostSymbols;
         bool mNeedsPlaceholderSymbol;
+      private:
+        DISALLOW_COPY_AND_ASSIGN(TLeftmostSymbolMaintainer);
     };
 
     TDependencyGraphBuilder(TDependencyGraph *graph)
diff --git a/src/compiler/translator/depgraph/DependencyGraphOutput.h b/src/compiler/translator/depgraph/DependencyGraphOutput.h
index 729c6a4..dbed837 100644
--- a/src/compiler/translator/depgraph/DependencyGraphOutput.h
+++ b/src/compiler/translator/depgraph/DependencyGraphOutput.h
@@ -10,18 +10,21 @@
 #include "compiler/translator/depgraph/DependencyGraph.h"
 #include "compiler/translator/InfoSink.h"
 
-class TDependencyGraphOutput : public TDependencyGraphTraverser {
-public:
+class TDependencyGraphOutput : public TDependencyGraphTraverser
+{
+  public:
     TDependencyGraphOutput(TInfoSinkBase& sink) : mSink(sink) {}
-    virtual void visitSymbol(TGraphSymbol* symbol);
-    virtual void visitArgument(TGraphArgument* parameter);
-    virtual void visitFunctionCall(TGraphFunctionCall* functionCall);
-    virtual void visitSelection(TGraphSelection* selection);
-    virtual void visitLoop(TGraphLoop* loop);
-    virtual void visitLogicalOp(TGraphLogicalOp* logicalOp);
+    void visitSymbol(TGraphSymbol* symbol) override;
+    void visitArgument(TGraphArgument* parameter) override;
+    void visitFunctionCall(TGraphFunctionCall* functionCall) override;
+    void visitSelection(TGraphSelection* selection) override;
+    void visitLoop(TGraphLoop* loop) override;
+    void visitLogicalOp(TGraphLogicalOp* logicalOp) override;
 
     void outputAllSpanningTrees(TDependencyGraph& graph);
-private:
+  private:
+    DISALLOW_COPY_AND_ASSIGN(TDependencyGraphOutput);
+
     void outputIndentation();
 
     TInfoSinkBase& mSink;
diff --git a/src/compiler/translator/timing/RestrictFragmentShaderTiming.h b/src/compiler/translator/timing/RestrictFragmentShaderTiming.h
index 296d4d0..f001745 100644
--- a/src/compiler/translator/timing/RestrictFragmentShaderTiming.h
+++ b/src/compiler/translator/timing/RestrictFragmentShaderTiming.h
@@ -12,23 +12,26 @@
 
 class TInfoSinkBase;
 
-class RestrictFragmentShaderTiming : TDependencyGraphTraverser {
-public:
-    RestrictFragmentShaderTiming(TInfoSinkBase& sink);
-    void enforceRestrictions(const TDependencyGraph& graph);
+class RestrictFragmentShaderTiming : TDependencyGraphTraverser
+{
+  public:
+    RestrictFragmentShaderTiming(TInfoSinkBase &sink);
+    void enforceRestrictions(const TDependencyGraph &graph);
     int numErrors() const { return mNumErrors; }
 
-    virtual void visitArgument(TGraphArgument* parameter);
-    virtual void visitSelection(TGraphSelection* selection);
-    virtual void visitLoop(TGraphLoop* loop);
-    virtual void visitLogicalOp(TGraphLogicalOp* logicalOp);
+    void visitArgument(TGraphArgument *parameter) override;
+    void visitSelection(TGraphSelection *selection) override;
+    void visitLoop(TGraphLoop *loop) override;
+    void visitLogicalOp(TGraphLogicalOp *logicalOp) override;
 
-private:
-    void beginError(const TIntermNode* node);
-    void validateUserDefinedFunctionCallUsage(const TDependencyGraph& graph);
-    bool isSamplingOp(const TIntermAggregate* intermFunctionCall) const;
+  private:
+    DISALLOW_COPY_AND_ASSIGN(RestrictFragmentShaderTiming);
 
-    TInfoSinkBase& mSink;
+    void beginError(const TIntermNode *node);
+    void validateUserDefinedFunctionCallUsage(const TDependencyGraph &graph);
+    bool isSamplingOp(const TIntermAggregate *intermFunctionCall) const;
+
+    TInfoSinkBase &mSink;
     int mNumErrors;
 
     typedef std::set<TString> StringSet;