Apply Chromium style fixes.
This addresses several minor code quality issues that are validated
in Chromium, but not yet applied to ANGLE:
* constructors and destructors must be defined out-of-line
* auto is not allowed for simple pointer types
* use override everywhere instead of virtual
* virtual functions must also be defined out-of-line
Slightly reduces binary size for me (~2k on Win, 150k on Linux).
Bug: angleproject:1569
Change-Id: I073ca3365188caf5f29fb28d9eb207903c1843e6
Reviewed-on: https://chromium-review.googlesource.com/779959
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index 9cda720..f6c5763 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -215,6 +215,10 @@
{
}
+DirectiveParser::~DirectiveParser()
+{
+}
+
void DirectiveParser::lex(Token *token)
{
do
diff --git a/src/compiler/preprocessor/DirectiveParser.h b/src/compiler/preprocessor/DirectiveParser.h
index 4229cba..29c30a8 100644
--- a/src/compiler/preprocessor/DirectiveParser.h
+++ b/src/compiler/preprocessor/DirectiveParser.h
@@ -26,6 +26,7 @@
Diagnostics *diagnostics,
DirectiveHandler *directiveHandler,
int maxMacroExpansionDepth);
+ ~DirectiveParser() override;
void lex(Token *token) override;
diff --git a/src/compiler/preprocessor/Input.cpp b/src/compiler/preprocessor/Input.cpp
index 3a473f7..0f2327b 100644
--- a/src/compiler/preprocessor/Input.cpp
+++ b/src/compiler/preprocessor/Input.cpp
@@ -18,6 +18,10 @@
{
}
+Input::~Input()
+{
+}
+
Input::Input(size_t count, const char *const string[], const int length[])
: mCount(count), mString(string)
{
diff --git a/src/compiler/preprocessor/Input.h b/src/compiler/preprocessor/Input.h
index d5f3858..8c7c7ee 100644
--- a/src/compiler/preprocessor/Input.h
+++ b/src/compiler/preprocessor/Input.h
@@ -18,6 +18,7 @@
{
public:
Input();
+ ~Input();
Input(size_t count, const char *const string[], const int length[]);
size_t count() const { return mCount; }
diff --git a/src/compiler/preprocessor/Macro.cpp b/src/compiler/preprocessor/Macro.cpp
index 6162767..52e2312 100644
--- a/src/compiler/preprocessor/Macro.cpp
+++ b/src/compiler/preprocessor/Macro.cpp
@@ -12,6 +12,14 @@
namespace pp
{
+Macro::Macro() : predefined(false), disabled(false), expansionCount(0), type(kTypeObj)
+{
+}
+
+Macro::~Macro()
+{
+}
+
bool Macro::equals(const Macro &other) const
{
return (type == other.type) && (name == other.name) && (parameters == other.parameters) &&
diff --git a/src/compiler/preprocessor/Macro.h b/src/compiler/preprocessor/Macro.h
index f835c42..c42e172 100644
--- a/src/compiler/preprocessor/Macro.h
+++ b/src/compiler/preprocessor/Macro.h
@@ -27,7 +27,8 @@
typedef std::vector<std::string> Parameters;
typedef std::vector<Token> Replacements;
- Macro() : predefined(false), disabled(false), expansionCount(0), type(kTypeObj) {}
+ Macro();
+ ~Macro();
bool equals(const Macro &other) const;
bool predefined;
diff --git a/src/compiler/preprocessor/MacroExpander.cpp b/src/compiler/preprocessor/MacroExpander.cpp
index cc115f9..d88d3a6 100644
--- a/src/compiler/preprocessor/MacroExpander.cpp
+++ b/src/compiler/preprocessor/MacroExpander.cpp
@@ -458,6 +458,10 @@
{
}
+MacroExpander::MacroContext::~MacroContext()
+{
+}
+
bool MacroExpander::MacroContext::empty() const
{
return index == replacements.size();
diff --git a/src/compiler/preprocessor/MacroExpander.h b/src/compiler/preprocessor/MacroExpander.h
index 7a4f5a9..fae7676 100644
--- a/src/compiler/preprocessor/MacroExpander.h
+++ b/src/compiler/preprocessor/MacroExpander.h
@@ -52,6 +52,7 @@
struct MacroContext
{
MacroContext();
+ ~MacroContext();
bool empty() const;
const Token &get();
void unget();
diff --git a/src/compiler/preprocessor/Tokenizer.h b/src/compiler/preprocessor/Tokenizer.h
index ce030a1..af4fd7c 100644
--- a/src/compiler/preprocessor/Tokenizer.h
+++ b/src/compiler/preprocessor/Tokenizer.h
@@ -34,7 +34,7 @@
};
Tokenizer(Diagnostics *diagnostics);
- ~Tokenizer();
+ ~Tokenizer() override;
bool init(size_t count, const char *const string[], const int length[]);
diff --git a/src/compiler/translator/Cache.cpp b/src/compiler/translator/Cache.cpp
index 07cc5b2..417e824 100644
--- a/src/compiler/translator/Cache.cpp
+++ b/src/compiler/translator/Cache.cpp
@@ -57,6 +57,10 @@
TCache *TCache::sCache = nullptr;
+TCache::TCache()
+{
+}
+
void TCache::initialize()
{
if (sCache == nullptr)
diff --git a/src/compiler/translator/Cache.h b/src/compiler/translator/Cache.h
index a45ada4..a182b07 100644
--- a/src/compiler/translator/Cache.h
+++ b/src/compiler/translator/Cache.h
@@ -49,7 +49,7 @@
unsigned char secondarySize);
private:
- TCache() {}
+ TCache();
union TypeKey {
TypeKey(TBasicType basicType,
diff --git a/src/compiler/translator/Types.cpp b/src/compiler/translator/Types.cpp
index d54196f..04e885a 100644
--- a/src/compiler/translator/Types.cpp
+++ b/src/compiler/translator/Types.cpp
@@ -223,6 +223,12 @@
{
}
+TType::TType(const TType &) = default;
+
+TType::~TType()
+{
+}
+
bool TType::canBeConstructed() const
{
switch (type)
diff --git a/src/compiler/translator/Types.h b/src/compiler/translator/Types.h
index fe9f25c..0ca83c7 100644
--- a/src/compiler/translator/Types.h
+++ b/src/compiler/translator/Types.h
@@ -194,8 +194,9 @@
TType(TInterfaceBlock *interfaceBlockIn,
TQualifier qualifierIn,
TLayoutQualifier layoutQualifierIn);
+ ~TType();
- TType(const TType &) = default;
+ TType(const TType &);
TType &operator=(const TType &) = default;
TBasicType getBasicType() const { return type; }
diff --git a/src/compiler/translator/blocklayoutHLSL.h b/src/compiler/translator/blocklayoutHLSL.h
index a0220dc..d1a98c8 100644
--- a/src/compiler/translator/blocklayoutHLSL.h
+++ b/src/compiler/translator/blocklayoutHLSL.h
@@ -35,8 +35,8 @@
HLSLBlockEncoder(HLSLBlockEncoderStrategy strategy, bool transposeMatrices);
- virtual void enterAggregateType();
- virtual void exitAggregateType();
+ void enterAggregateType() override;
+ void exitAggregateType() override;
void skipRegisters(unsigned int numRegisters);
bool isPacked() const { return mEncoderStrategy == ENCODE_PACKED; }
@@ -44,16 +44,16 @@
static HLSLBlockEncoderStrategy GetStrategyFor(ShShaderOutput outputType);
protected:
- virtual void getBlockLayoutInfo(GLenum type,
- unsigned int arraySize,
- bool isRowMajorMatrix,
- int *arrayStrideOut,
- int *matrixStrideOut);
- virtual void advanceOffset(GLenum type,
- unsigned int arraySize,
- bool isRowMajorMatrix,
- int arrayStride,
- int matrixStride);
+ void getBlockLayoutInfo(GLenum type,
+ unsigned int arraySize,
+ bool isRowMajorMatrix,
+ int *arrayStrideOut,
+ int *matrixStrideOut) override;
+ void advanceOffset(GLenum type,
+ unsigned int arraySize,
+ bool isRowMajorMatrix,
+ int arrayStride,
+ int matrixStride) override;
HLSLBlockEncoderStrategy mEncoderStrategy;
bool mTransposeMatrices;