preprocessor: Miscellaneous cleanups
- Use full header paths in includes
- Use ASSERT instead of assert
- Use angle::NonCopyable instead of PP_DISALLOW_COPY_AND_ASSIGN
- Use range-for in a couple places
- Remove pp_utils.h
BUG=angleproject:1522
Change-Id: If107fef89e8465bca65cf664926d1051c5d1e232
Reviewed-on: https://chromium-review.googlesource.com/387212
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
diff --git a/src/compiler/preprocessor/DiagnosticsBase.cpp b/src/compiler/preprocessor/DiagnosticsBase.cpp
index 3281206..fcb24e4 100644
--- a/src/compiler/preprocessor/DiagnosticsBase.cpp
+++ b/src/compiler/preprocessor/DiagnosticsBase.cpp
@@ -4,9 +4,9 @@
// found in the LICENSE file.
//
-#include "DiagnosticsBase.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
-#include <cassert>
+#include "common/debug.h"
namespace pp
{
@@ -31,7 +31,7 @@
if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
return PP_WARNING;
- assert(false);
+ UNREACHABLE();
return PP_ERROR;
}
@@ -133,8 +133,8 @@
return "macro name with a double underscore is reserved - unintented behavior is possible";
// Warnings end.
default:
- assert(false);
- return "";
+ UNREACHABLE();
+ return "";
}
}
diff --git a/src/compiler/preprocessor/DirectiveHandlerBase.cpp b/src/compiler/preprocessor/DirectiveHandlerBase.cpp
index ef35c6e..049dae9 100644
--- a/src/compiler/preprocessor/DirectiveHandlerBase.cpp
+++ b/src/compiler/preprocessor/DirectiveHandlerBase.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "DirectiveHandlerBase.h"
+#include "compiler/preprocessor/DirectiveHandlerBase.h"
namespace pp
{
diff --git a/src/compiler/preprocessor/DirectiveParser.cpp b/src/compiler/preprocessor/DirectiveParser.cpp
index ebe72f1..643f73b 100644
--- a/src/compiler/preprocessor/DirectiveParser.cpp
+++ b/src/compiler/preprocessor/DirectiveParser.cpp
@@ -4,19 +4,19 @@
// found in the LICENSE file.
//
-#include "DirectiveParser.h"
+#include "compiler/preprocessor/DirectiveParser.h"
#include <algorithm>
-#include <cassert>
#include <cstdlib>
#include <sstream>
-#include "DiagnosticsBase.h"
-#include "DirectiveHandlerBase.h"
-#include "ExpressionParser.h"
-#include "MacroExpander.h"
-#include "Token.h"
-#include "Tokenizer.h"
+#include "common/debug.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
+#include "compiler/preprocessor/DirectiveHandlerBase.h"
+#include "compiler/preprocessor/ExpressionParser.h"
+#include "compiler/preprocessor/MacroExpander.h"
+#include "compiler/preprocessor/Token.h"
+#include "compiler/preprocessor/Tokenizer.h"
namespace {
enum DirectiveType
@@ -248,7 +248,7 @@
void DirectiveParser::parseDirective(Token *token)
{
- assert(token->type == Token::PP_HASH);
+ ASSERT(token->type == Token::PP_HASH);
mTokenizer->lex(token);
if (isEOD(token))
@@ -314,8 +314,8 @@
parseLine(token);
break;
default:
- assert(false);
- break;
+ UNREACHABLE();
+ break;
}
skipUntilEOD(mTokenizer, token);
@@ -328,7 +328,7 @@
void DirectiveParser::parseDefine(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_DEFINE);
+ ASSERT(getDirective(token) == DIRECTIVE_DEFINE);
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
@@ -428,7 +428,7 @@
void DirectiveParser::parseUndef(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_UNDEF);
+ ASSERT(getDirective(token) == DIRECTIVE_UNDEF);
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
@@ -470,25 +470,25 @@
void DirectiveParser::parseIf(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_IF);
+ ASSERT(getDirective(token) == DIRECTIVE_IF);
parseConditionalIf(token);
}
void DirectiveParser::parseIfdef(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_IFDEF);
+ ASSERT(getDirective(token) == DIRECTIVE_IFDEF);
parseConditionalIf(token);
}
void DirectiveParser::parseIfndef(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_IFNDEF);
+ ASSERT(getDirective(token) == DIRECTIVE_IFNDEF);
parseConditionalIf(token);
}
void DirectiveParser::parseElse(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_ELSE);
+ ASSERT(getDirective(token) == DIRECTIVE_ELSE);
if (mConditionalStack.empty())
{
@@ -529,7 +529,7 @@
void DirectiveParser::parseElif(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_ELIF);
+ ASSERT(getDirective(token) == DIRECTIVE_ELIF);
if (mConditionalStack.empty())
{
@@ -569,7 +569,7 @@
void DirectiveParser::parseEndif(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_ENDIF);
+ ASSERT(getDirective(token) == DIRECTIVE_ENDIF);
if (mConditionalStack.empty())
{
@@ -593,7 +593,7 @@
void DirectiveParser::parseError(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_ERROR);
+ ASSERT(getDirective(token) == DIRECTIVE_ERROR);
std::ostringstream stream;
mTokenizer->lex(token);
@@ -608,7 +608,7 @@
// Parses pragma of form: #pragma name[(value)].
void DirectiveParser::parsePragma(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_PRAGMA);
+ ASSERT(getDirective(token) == DIRECTIVE_PRAGMA);
enum State
{
@@ -669,7 +669,7 @@
void DirectiveParser::parseExtension(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_EXTENSION);
+ ASSERT(getDirective(token) == DIRECTIVE_EXTENSION);
enum State
{
@@ -750,7 +750,7 @@
void DirectiveParser::parseVersion(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_VERSION);
+ ASSERT(getDirective(token) == DIRECTIVE_VERSION);
if (mPastFirstStatement)
{
@@ -837,7 +837,7 @@
void DirectiveParser::parseLine(Token *token)
{
- assert(getDirective(token) == DIRECTIVE_LINE);
+ ASSERT(getDirective(token) == DIRECTIVE_LINE);
bool valid = true;
bool parsedFileNumber = false;
@@ -938,8 +938,8 @@
expression = parseExpressionIfdef(token) == 0 ? 1 : 0;
break;
default:
- assert(false);
- break;
+ UNREACHABLE();
+ break;
}
block.skipGroup = expression == 0;
block.foundValidGroup = expression != 0;
@@ -949,8 +949,7 @@
int DirectiveParser::parseExpressionIf(Token *token)
{
- assert((getDirective(token) == DIRECTIVE_IF) ||
- (getDirective(token) == DIRECTIVE_ELIF));
+ ASSERT((getDirective(token) == DIRECTIVE_IF) || (getDirective(token) == DIRECTIVE_ELIF));
DefinedParser definedParser(mTokenizer, mMacroSet, mDiagnostics);
MacroExpander macroExpander(&definedParser, mMacroSet, mDiagnostics);
@@ -977,8 +976,7 @@
int DirectiveParser::parseExpressionIfdef(Token *token)
{
- assert((getDirective(token) == DIRECTIVE_IFDEF) ||
- (getDirective(token) == DIRECTIVE_IFNDEF));
+ ASSERT((getDirective(token) == DIRECTIVE_IFDEF) || (getDirective(token) == DIRECTIVE_IFNDEF));
mTokenizer->lex(token);
if (token->type != Token::IDENTIFIER)
diff --git a/src/compiler/preprocessor/DirectiveParser.h b/src/compiler/preprocessor/DirectiveParser.h
index 2888e28..f0e889c 100644
--- a/src/compiler/preprocessor/DirectiveParser.h
+++ b/src/compiler/preprocessor/DirectiveParser.h
@@ -7,10 +7,9 @@
#ifndef COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_
#define COMPILER_PREPROCESSOR_DIRECTIVEPARSER_H_
-#include "Lexer.h"
-#include "Macro.h"
-#include "pp_utils.h"
-#include "SourceLocation.h"
+#include "compiler/preprocessor/Lexer.h"
+#include "compiler/preprocessor/Macro.h"
+#include "compiler/preprocessor/SourceLocation.h"
namespace pp
{
@@ -30,7 +29,6 @@
void lex(Token *token) override;
private:
- PP_DISALLOW_COPY_AND_ASSIGN(DirectiveParser);
void parseDirective(Token *token);
void parseDefine(Token *token);
diff --git a/src/compiler/preprocessor/ExpressionParser.h b/src/compiler/preprocessor/ExpressionParser.h
index 841c67b..0f2901b 100644
--- a/src/compiler/preprocessor/ExpressionParser.h
+++ b/src/compiler/preprocessor/ExpressionParser.h
@@ -7,8 +7,8 @@
#ifndef COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_
#define COMPILER_PREPROCESSOR_EXPRESSIONPARSER_H_
-#include "DiagnosticsBase.h"
-#include "pp_utils.h"
+#include "common/angleutils.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
namespace pp
{
@@ -16,7 +16,7 @@
class Lexer;
struct Token;
-class ExpressionParser
+class ExpressionParser : angle::NonCopyable
{
public:
struct ErrorSettings
@@ -34,8 +34,6 @@
bool *valid);
private:
- PP_DISALLOW_COPY_AND_ASSIGN(ExpressionParser);
-
Lexer *mLexer;
Diagnostics *mDiagnostics;
};
diff --git a/src/compiler/preprocessor/Input.cpp b/src/compiler/preprocessor/Input.cpp
index 5541d46..8bce56f 100644
--- a/src/compiler/preprocessor/Input.cpp
+++ b/src/compiler/preprocessor/Input.cpp
@@ -4,12 +4,13 @@
// found in the LICENSE file.
//
-#include "Input.h"
+#include "compiler/preprocessor/Input.h"
#include <algorithm>
-#include <cassert>
#include <cstring>
+#include "common/debug.h"
+
namespace pp
{
@@ -32,7 +33,7 @@
const char *Input::skipChar()
{
// This function should only be called when there is a character to skip.
- assert(mReadLoc.cIndex < mLength[mReadLoc.sIndex]);
+ ASSERT(mReadLoc.cIndex < mLength[mReadLoc.sIndex]);
++mReadLoc.cIndex;
if (mReadLoc.cIndex == mLength[mReadLoc.sIndex])
{
diff --git a/src/compiler/preprocessor/Input.h b/src/compiler/preprocessor/Input.h
index a1de7dd..ecbb049 100644
--- a/src/compiler/preprocessor/Input.h
+++ b/src/compiler/preprocessor/Input.h
@@ -7,7 +7,7 @@
#ifndef COMPILER_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
-#include <stddef.h>
+#include <cstddef>
#include <vector>
namespace pp
diff --git a/src/compiler/preprocessor/Lexer.cpp b/src/compiler/preprocessor/Lexer.cpp
index 7c663ee..89cb3cf 100644
--- a/src/compiler/preprocessor/Lexer.cpp
+++ b/src/compiler/preprocessor/Lexer.cpp
@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
-#include "Lexer.h"
+#include "compiler/preprocessor/Lexer.h"
namespace pp
{
diff --git a/src/compiler/preprocessor/Lexer.h b/src/compiler/preprocessor/Lexer.h
index 990dc5e..775bc0a 100644
--- a/src/compiler/preprocessor/Lexer.h
+++ b/src/compiler/preprocessor/Lexer.h
@@ -7,12 +7,14 @@
#ifndef COMPILER_PREPROCESSOR_LEXER_H_
#define COMPILER_PREPROCESSOR_LEXER_H_
+#include "common/angleutils.h"
+
namespace pp
{
struct Token;
-class Lexer
+class Lexer : angle::NonCopyable
{
public:
virtual ~Lexer();
diff --git a/src/compiler/preprocessor/Macro.cpp b/src/compiler/preprocessor/Macro.cpp
index 4c4d5fd..f5c9439 100644
--- a/src/compiler/preprocessor/Macro.cpp
+++ b/src/compiler/preprocessor/Macro.cpp
@@ -4,11 +4,10 @@
// found in the LICENSE file.
//
-#include "Macro.h"
+#include "compiler/preprocessor/Macro.h"
-#include <sstream>
-
-#include "Token.h"
+#include "common/angleutils.h"
+#include "compiler/preprocessor/Token.h"
namespace pp
{
@@ -23,12 +22,9 @@
void PredefineMacro(MacroSet *macroSet, const char *name, int value)
{
- std::ostringstream stream;
- stream << value;
-
Token token;
token.type = Token::CONST_INT;
- token.text = stream.str();
+ token.text = ToString(value);
Macro macro;
macro.predefined = true;
diff --git a/src/compiler/preprocessor/MacroExpander.cpp b/src/compiler/preprocessor/MacroExpander.cpp
index a4519f2..f38b396 100644
--- a/src/compiler/preprocessor/MacroExpander.cpp
+++ b/src/compiler/preprocessor/MacroExpander.cpp
@@ -4,13 +4,13 @@
// found in the LICENSE file.
//
-#include "MacroExpander.h"
+#include "compiler/preprocessor/MacroExpander.h"
#include <algorithm>
-#include <sstream>
-#include "DiagnosticsBase.h"
-#include "Token.h"
+#include "common/debug.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
+#include "compiler/preprocessor/Token.h"
namespace pp
{
@@ -45,8 +45,6 @@
}
private:
- PP_DISALLOW_COPY_AND_ASSIGN(TokenLexer);
-
TokenVector mTokens;
TokenVector::const_iterator mIter;
};
@@ -60,9 +58,9 @@
MacroExpander::~MacroExpander()
{
- for (std::size_t i = 0; i < mContextStack.size(); ++i)
+ for (MacroContext *context : mContextStack)
{
- delete mContextStack[i];
+ delete context;
}
}
@@ -121,7 +119,7 @@
}
else
{
- assert(mTotalTokensInContexts == 0);
+ ASSERT(mTotalTokensInContexts == 0);
mLexer->lex(token);
}
}
@@ -132,11 +130,11 @@
{
MacroContext *context = mContextStack.back();
context->unget();
- assert(context->replacements[context->index] == token);
+ ASSERT(context->replacements[context->index] == token);
}
else
{
- assert(!mReserveToken.get());
+ ASSERT(!mReserveToken.get());
mReserveToken.reset(new Token(token));
}
}
@@ -154,10 +152,10 @@
bool MacroExpander::pushMacro(const Macro ¯o, const Token &identifier)
{
- assert(!macro.disabled);
- assert(!identifier.expansionDisabled());
- assert(identifier.type == Token::IDENTIFIER);
- assert(identifier.text == macro.name);
+ ASSERT(!macro.disabled);
+ ASSERT(!identifier.expansionDisabled());
+ ASSERT(identifier.type == Token::IDENTIFIER);
+ ASSERT(identifier.text == macro.name);
macro.expansionCount++;
@@ -178,14 +176,14 @@
void MacroExpander::popMacro()
{
- assert(!mContextStack.empty());
+ ASSERT(!mContextStack.empty());
MacroContext *context = mContextStack.back();
mContextStack.pop_back();
- assert(context->empty());
- assert(context->macro->disabled);
- assert(context->macro->expansionCount > 0);
+ ASSERT(context->empty());
+ ASSERT(context->macro->disabled);
+ ASSERT(context->macro->expansionCount > 0);
context->macro->disabled = false;
context->macro->expansionCount--;
mTotalTokensInContexts -= context->replacements.size();
@@ -213,25 +211,21 @@
const char kLine[] = "__LINE__";
const char kFile[] = "__FILE__";
- assert(replacements->size() == 1);
+ ASSERT(replacements->size() == 1);
Token& repl = replacements->front();
if (macro.name == kLine)
{
- std::ostringstream stream;
- stream << identifier.location.line;
- repl.text = stream.str();
+ repl.text = ToString(identifier.location.line);
}
else if (macro.name == kFile)
{
- std::ostringstream stream;
- stream << identifier.location.file;
- repl.text = stream.str();
+ repl.text = ToString(identifier.location.file);
}
}
}
else
{
- assert(macro.type == Macro::kTypeFunc);
+ ASSERT(macro.type == Macro::kTypeFunc);
std::vector<MacroArg> args;
args.reserve(macro.parameters.size());
if (!collectMacroArgs(macro, identifier, &args, &replacementLocation))
@@ -262,10 +256,12 @@
{
Token token;
getToken(&token);
- assert(token.type == '(');
+ ASSERT(token.type == '(');
args->push_back(MacroArg());
- for (int openParens = 1; openParens != 0; )
+
+ int openParens = 1;
+ while (openParens != 0)
{
getToken(&token);
@@ -332,9 +328,8 @@
// This step expands each argument individually before they are
// inserted into the macro body.
size_t numTokens = 0;
- for (std::size_t i = 0; i < args->size(); ++i)
+ for (auto &arg : *args)
{
- MacroArg &arg = args->at(i);
TokenLexer lexer(&arg);
MacroExpander expander(&lexer, mMacroSet, mDiagnostics);
@@ -401,5 +396,25 @@
}
}
+MacroExpander::MacroContext::MacroContext() : macro(0), index(0)
+{
+}
+
+bool MacroExpander::MacroContext::empty() const
+{
+ return index == replacements.size();
+}
+
+const Token &MacroExpander::MacroContext::get()
+{
+ return replacements[index++];
+}
+
+void MacroExpander::MacroContext::unget()
+{
+ ASSERT(index > 0);
+ --index;
+}
+
} // namespace pp
diff --git a/src/compiler/preprocessor/MacroExpander.h b/src/compiler/preprocessor/MacroExpander.h
index 5e5dbe9..77c767c 100644
--- a/src/compiler/preprocessor/MacroExpander.h
+++ b/src/compiler/preprocessor/MacroExpander.h
@@ -7,13 +7,11 @@
#ifndef COMPILER_PREPROCESSOR_MACROEXPANDER_H_
#define COMPILER_PREPROCESSOR_MACROEXPANDER_H_
-#include <cassert>
#include <memory>
#include <vector>
-#include "Lexer.h"
-#include "Macro.h"
-#include "pp_utils.h"
+#include "compiler/preprocessor/Lexer.h"
+#include "compiler/preprocessor/Macro.h"
namespace pp
{
@@ -30,8 +28,6 @@
void lex(Token *token) override;
private:
- PP_DISALLOW_COPY_AND_ASSIGN(MacroExpander);
-
void getToken(Token *token);
void ungetToken(const Token &token);
bool isNextTokenLeftParen();
@@ -54,28 +50,14 @@
struct MacroContext
{
+ MacroContext();
+ bool empty() const;
+ const Token &get();
+ void unget();
+
const Macro *macro;
std::size_t index;
std::vector<Token> replacements;
-
- MacroContext()
- : macro(0),
- index(0)
- {
- }
- bool empty() const
- {
- return index == replacements.size();
- }
- const Token &get()
- {
- return replacements[index++];
- }
- void unget()
- {
- assert(index > 0);
- --index;
- }
};
Lexer *mLexer;
diff --git a/src/compiler/preprocessor/Preprocessor.cpp b/src/compiler/preprocessor/Preprocessor.cpp
index 2fa87fe..1709d66 100644
--- a/src/compiler/preprocessor/Preprocessor.cpp
+++ b/src/compiler/preprocessor/Preprocessor.cpp
@@ -4,16 +4,15 @@
// found in the LICENSE file.
//
-#include "Preprocessor.h"
+#include "compiler/preprocessor/Preprocessor.h"
-#include <cassert>
-
-#include "DiagnosticsBase.h"
-#include "DirectiveParser.h"
-#include "Macro.h"
-#include "MacroExpander.h"
-#include "Token.h"
-#include "Tokenizer.h"
+#include "common/debug.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
+#include "compiler/preprocessor/DirectiveParser.h"
+#include "compiler/preprocessor/Macro.h"
+#include "compiler/preprocessor/MacroExpander.h"
+#include "compiler/preprocessor/Token.h"
+#include "compiler/preprocessor/Tokenizer.h"
namespace pp
{
@@ -78,8 +77,8 @@
// Convert preprocessing tokens to compiler tokens or report
// diagnostics.
case Token::PP_HASH:
- assert(false);
- break;
+ UNREACHABLE();
+ break;
case Token::PP_NUMBER:
mImpl->diagnostics->report(Diagnostics::PP_INVALID_NUMBER,
token->location, token->text);
diff --git a/src/compiler/preprocessor/Preprocessor.h b/src/compiler/preprocessor/Preprocessor.h
index fe25daa..cd69978 100644
--- a/src/compiler/preprocessor/Preprocessor.h
+++ b/src/compiler/preprocessor/Preprocessor.h
@@ -7,9 +7,9 @@
#ifndef COMPILER_PREPROCESSOR_PREPROCESSOR_H_
#define COMPILER_PREPROCESSOR_PREPROCESSOR_H_
-#include <stddef.h>
+#include <cstddef>
-#include "pp_utils.h"
+#include "common/angleutils.h"
namespace pp
{
@@ -19,7 +19,7 @@
struct PreprocessorImpl;
struct Token;
-class Preprocessor
+class Preprocessor : angle::NonCopyable
{
public:
Preprocessor(Diagnostics *diagnostics, DirectiveHandler *directiveHandler);
@@ -44,8 +44,6 @@
void setMaxTokenSize(size_t maxTokenSize);
private:
- PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
-
PreprocessorImpl *mImpl;
};
diff --git a/src/compiler/preprocessor/Token.cpp b/src/compiler/preprocessor/Token.cpp
index d102654..41610a4 100644
--- a/src/compiler/preprocessor/Token.cpp
+++ b/src/compiler/preprocessor/Token.cpp
@@ -4,11 +4,10 @@
// found in the LICENSE file.
//
-#include "Token.h"
+#include "compiler/preprocessor/Token.h"
-#include <cassert>
-
-#include "numeric_lex.h"
+#include "common/debug.h"
+#include "compiler/preprocessor/numeric_lex.h"
namespace pp
{
@@ -55,19 +54,19 @@
bool Token::iValue(int *value) const
{
- assert(type == CONST_INT);
+ ASSERT(type == CONST_INT);
return numeric_lex_int(text, value);
}
bool Token::uValue(unsigned int *value) const
{
- assert(type == CONST_INT);
+ ASSERT(type == CONST_INT);
return numeric_lex_int(text, value);
}
bool Token::fValue(float *value) const
{
- assert(type == CONST_FLOAT);
+ ASSERT(type == CONST_FLOAT);
return numeric_lex_float(text, value);
}
diff --git a/src/compiler/preprocessor/Token.h b/src/compiler/preprocessor/Token.h
index 347c47e..716503b 100644
--- a/src/compiler/preprocessor/Token.h
+++ b/src/compiler/preprocessor/Token.h
@@ -10,7 +10,7 @@
#include <ostream>
#include <string>
-#include "SourceLocation.h"
+#include "compiler/preprocessor/SourceLocation.h"
namespace pp
{
@@ -113,7 +113,7 @@
return !lhs.equals(rhs);
}
-extern std::ostream &operator<<(std::ostream &out, const Token &token);
+std::ostream &operator<<(std::ostream &out, const Token &token);
} // namepsace pp
diff --git a/src/compiler/preprocessor/Tokenizer.cpp b/src/compiler/preprocessor/Tokenizer.cpp
index 5ef0e5e..40e910e 100644
--- a/src/compiler/preprocessor/Tokenizer.cpp
+++ b/src/compiler/preprocessor/Tokenizer.cpp
@@ -720,10 +720,10 @@
#pragma warning(disable: 4005)
#endif
-#include "Tokenizer.h"
+#include "compiler/preprocessor/Tokenizer.h"
-#include "DiagnosticsBase.h"
-#include "Token.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
+#include "compiler/preprocessor/Token.h"
#if defined(__GNUC__)
// Triggered by the auto-generated yy_fatal_error function.
@@ -2794,9 +2794,7 @@
namespace pp {
-Tokenizer::Tokenizer(Diagnostics *diagnostics)
- : mHandle(0),
- mMaxTokenSize(256)
+Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)
{
mContext.diagnostics = diagnostics;
}
@@ -2853,7 +2851,7 @@
bool Tokenizer::initScanner()
{
- if ((mHandle == NULL) && pplex_init_extra(&mContext,&mHandle))
+ if ((mHandle == nullptr) && pplex_init_extra(&mContext, &mHandle))
return false;
pprestart(0,mHandle);
@@ -2862,11 +2860,11 @@
void Tokenizer::destroyScanner()
{
- if (mHandle == NULL)
+ if (mHandle == nullptr)
return;
pplex_destroy(mHandle);
- mHandle = NULL;
+ mHandle = nullptr;
}
} // namespace pp
diff --git a/src/compiler/preprocessor/Tokenizer.h b/src/compiler/preprocessor/Tokenizer.h
index 49e64fa..6dfb19c 100644
--- a/src/compiler/preprocessor/Tokenizer.h
+++ b/src/compiler/preprocessor/Tokenizer.h
@@ -7,9 +7,9 @@
#ifndef COMPILER_PREPROCESSOR_TOKENIZER_H_
#define COMPILER_PREPROCESSOR_TOKENIZER_H_
-#include "Input.h"
-#include "Lexer.h"
-#include "pp_utils.h"
+#include "common/angleutils.h"
+#include "compiler/preprocessor/Input.h"
+#include "compiler/preprocessor/Lexer.h"
namespace pp
{
@@ -45,7 +45,6 @@
void lex(Token *token) override;
private:
- PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer);
bool initScanner();
void destroyScanner();
diff --git a/src/compiler/preprocessor/Tokenizer.l b/src/compiler/preprocessor/Tokenizer.l
index d316da8..62eb4ca 100644
--- a/src/compiler/preprocessor/Tokenizer.l
+++ b/src/compiler/preprocessor/Tokenizer.l
@@ -27,10 +27,10 @@
#pragma warning(disable: 4005)
#endif
-#include "Tokenizer.h"
+#include "compiler/preprocessor/Tokenizer.h"
-#include "DiagnosticsBase.h"
-#include "Token.h"
+#include "compiler/preprocessor/DiagnosticsBase.h"
+#include "compiler/preprocessor/Token.h"
#if defined(__GNUC__)
// Triggered by the auto-generated yy_fatal_error function.
@@ -280,9 +280,7 @@
namespace pp {
-Tokenizer::Tokenizer(Diagnostics *diagnostics)
- : mHandle(0),
- mMaxTokenSize(256)
+Tokenizer::Tokenizer(Diagnostics *diagnostics) : mHandle(nullptr), mMaxTokenSize(256)
{
mContext.diagnostics = diagnostics;
}
@@ -339,7 +337,7 @@
bool Tokenizer::initScanner()
{
- if ((mHandle == NULL) && yylex_init_extra(&mContext, &mHandle))
+ if ((mHandle == nullptr) && yylex_init_extra(&mContext, &mHandle))
return false;
yyrestart(0, mHandle);
@@ -348,11 +346,11 @@
void Tokenizer::destroyScanner()
{
- if (mHandle == NULL)
+ if (mHandle == nullptr)
return;
yylex_destroy(mHandle);
- mHandle = NULL;
+ mHandle = nullptr;
}
} // namespace pp
diff --git a/src/compiler/preprocessor/pp_utils.h b/src/compiler/preprocessor/pp_utils.h
deleted file mode 100644
index 9fba938..0000000
--- a/src/compiler/preprocessor/pp_utils.h
+++ /dev/null
@@ -1,18 +0,0 @@
-//
-// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-//
-
-// pp_utils.h: Common preprocessor utilities
-
-#ifndef COMPILER_PREPROCESSOR_PPUTILS_H_
-#define COMPILER_PREPROCESSOR_PPUTILS_H_
-
-// A macro to disallow the copy constructor and operator= functions
-// This must be used in the private: declarations for a class.
-#define PP_DISALLOW_COPY_AND_ASSIGN(TypeName) \
- TypeName(const TypeName &); \
- void operator=(const TypeName &)
-
-#endif // COMPILER_PREPROCESSOR_PPUTILS_H_