Commit 054f7ed0 by Corentin Wallez Committed by Commit Bot

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: 's avatarGeoff Lang <geofflang@chromium.org>
parent 6a0e4e52
......@@ -112,6 +112,10 @@ static_library("preprocessor") {
configs -= angle_undefine_configs
configs += [ ":internal_config" ]
public_deps = [
":angle_common",
]
}
config("translator_static_config") {
......
......@@ -156,6 +156,14 @@ size_t FormatStringIntoVector(const char *fmt, va_list vararg, std::vector<char>
std::string FormatString(const char *fmt, va_list vararg);
std::string FormatString(const char *fmt, ...);
template <typename T>
std::string ToString(const T &value)
{
std::ostringstream o;
o << value;
return o.str();
}
// snprintf is not defined with MSVC prior to to msvc14
#if defined(_MSC_VER) && _MSC_VER < 1900
#define snprintf _snprintf
......
......@@ -234,7 +234,6 @@
'compiler/preprocessor/Tokenizer.h',
'compiler/preprocessor/Tokenizer.l',
'compiler/preprocessor/numeric_lex.h',
'compiler/preprocessor/pp_utils.h',
],
},
# Everything below this is duplicated in the GN build. If you change
......@@ -244,6 +243,7 @@
{
'target_name': 'preprocessor',
'type': 'static_library',
'dependencies': [ 'angle_common' ],
'includes': [ '../build/common_defines.gypi', ],
'sources': [ '<@(angle_preprocessor_sources)', ],
},
......
......@@ -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 @@ Diagnostics::Severity Diagnostics::severity(ID id)
if ((id > PP_WARNING_BEGIN) && (id < PP_WARNING_END))
return PP_WARNING;
assert(false);
UNREACHABLE();
return PP_ERROR;
}
......@@ -133,8 +133,8 @@ std::string Diagnostics::message(ID id)
return "macro name with a double underscore is reserved - unintented behavior is possible";
// Warnings end.
default:
assert(false);
return "";
UNREACHABLE();
return "";
}
}
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
#include "DirectiveHandlerBase.h"
#include "compiler/preprocessor/DirectiveHandlerBase.h"
namespace pp
{
......
......@@ -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::lex(Token *token)
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 @@ void DirectiveParser::parseDirective(Token *token)
parseLine(token);
break;
default:
assert(false);
break;
UNREACHABLE();
break;
}
skipUntilEOD(mTokenizer, token);
......@@ -328,7 +328,7 @@ void DirectiveParser::parseDirective(Token *token)
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::parseDefine(Token *token)
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::parseUndef(Token *token)
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::parseElse(Token *token)
void DirectiveParser::parseElif(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ELIF);
ASSERT(getDirective(token) == DIRECTIVE_ELIF);
if (mConditionalStack.empty())
{
......@@ -569,7 +569,7 @@ void DirectiveParser::parseElif(Token *token)
void DirectiveParser::parseEndif(Token *token)
{
assert(getDirective(token) == DIRECTIVE_ENDIF);
ASSERT(getDirective(token) == DIRECTIVE_ENDIF);
if (mConditionalStack.empty())
{
......@@ -593,7 +593,7 @@ void DirectiveParser::parseEndif(Token *token)
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 @@ void DirectiveParser::parseError(Token *token)
// 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::parsePragma(Token *token)
void DirectiveParser::parseExtension(Token *token)
{
assert(getDirective(token) == DIRECTIVE_EXTENSION);
ASSERT(getDirective(token) == DIRECTIVE_EXTENSION);
enum State
{
......@@ -750,7 +750,7 @@ void DirectiveParser::parseExtension(Token *token)
void DirectiveParser::parseVersion(Token *token)
{
assert(getDirective(token) == DIRECTIVE_VERSION);
ASSERT(getDirective(token) == DIRECTIVE_VERSION);
if (mPastFirstStatement)
{
......@@ -837,7 +837,7 @@ void DirectiveParser::parseVersion(Token *token)
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 @@ void DirectiveParser::parseConditionalIf(Token *token)
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 @@ void DirectiveParser::parseConditionalIf(Token *token)
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::parseExpressionIf(Token *token)
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)
......
......@@ -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 @@ class DirectiveParser : public Lexer
void lex(Token *token) override;
private:
PP_DISALLOW_COPY_AND_ASSIGN(DirectiveParser);
void parseDirective(Token *token);
void parseDefine(Token *token);
......
......@@ -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 @@ namespace pp
class Lexer;
struct Token;
class ExpressionParser
class ExpressionParser : angle::NonCopyable
{
public:
struct ErrorSettings
......@@ -34,8 +34,6 @@ class ExpressionParser
bool *valid);
private:
PP_DISALLOW_COPY_AND_ASSIGN(ExpressionParser);
Lexer *mLexer;
Diagnostics *mDiagnostics;
};
......
......@@ -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 @@ Input::Input(size_t count, const char *const string[], const int length[]) :
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])
{
......
......@@ -7,7 +7,7 @@
#ifndef COMPILER_PREPROCESSOR_INPUT_H_
#define COMPILER_PREPROCESSOR_INPUT_H_
#include <stddef.h>
#include <cstddef>
#include <vector>
namespace pp
......
......@@ -4,7 +4,7 @@
// found in the LICENSE file.
//
#include "Lexer.h"
#include "compiler/preprocessor/Lexer.h"
namespace pp
{
......
......@@ -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();
......
......@@ -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 @@ bool Macro::equals(const Macro &other) const
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;
......
......@@ -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 @@ class TokenLexer : public Lexer
}
private:
PP_DISALLOW_COPY_AND_ASSIGN(TokenLexer);
TokenVector mTokens;
TokenVector::const_iterator mIter;
};
......@@ -60,9 +58,9 @@ MacroExpander::MacroExpander(Lexer *lexer, MacroSet *macroSet, Diagnostics *diag
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 @@ void MacroExpander::getToken(Token *token)
}
else
{
assert(mTotalTokensInContexts == 0);
ASSERT(mTotalTokensInContexts == 0);
mLexer->lex(token);
}
}
......@@ -132,11 +130,11 @@ void MacroExpander::ungetToken(const Token &token)
{
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::isNextTokenLeftParen()
bool MacroExpander::pushMacro(const Macro &macro, 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 @@ bool MacroExpander::pushMacro(const Macro &macro, const Token &identifier)
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 @@ bool MacroExpander::expandMacro(const Macro &macro,
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 @@ bool MacroExpander::collectMacroArgs(const Macro &macro,
{
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 @@ bool MacroExpander::collectMacroArgs(const Macro &macro,
// 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 @@ void MacroExpander::replaceMacroParams(const Macro &macro,
}
}
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
......@@ -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 @@ class MacroExpander : public Lexer
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 @@ class MacroExpander : public Lexer
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;
......
......@@ -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 @@ void Preprocessor::lex(Token *token)
// 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);
......
......@@ -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 @@ class DirectiveHandler;
struct PreprocessorImpl;
struct Token;
class Preprocessor
class Preprocessor : angle::NonCopyable
{
public:
Preprocessor(Diagnostics *diagnostics, DirectiveHandler *directiveHandler);
......@@ -44,8 +44,6 @@ class Preprocessor
void setMaxTokenSize(size_t maxTokenSize);
private:
PP_DISALLOW_COPY_AND_ASSIGN(Preprocessor);
PreprocessorImpl *mImpl;
};
......
......@@ -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 @@ void Token::setExpansionDisabled(bool disable)
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);
}
......
......@@ -10,7 +10,7 @@
#include <ostream>
#include <string>
#include "SourceLocation.h"
#include "compiler/preprocessor/SourceLocation.h"
namespace pp
{
......@@ -113,7 +113,7 @@ inline bool operator!=(const Token &lhs, const Token &rhs)
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
......
......@@ -720,10 +720,10 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
#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 @@ void ppfree (void * ptr , yyscan_t yyscanner)
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 @@ void Tokenizer::lex(Token *token)
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 @@ bool Tokenizer::initScanner()
void Tokenizer::destroyScanner()
{
if (mHandle == NULL)
if (mHandle == nullptr)
return;
pplex_destroy(mHandle);
mHandle = NULL;
mHandle = nullptr;
}
} // namespace pp
......
......@@ -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 @@ class Tokenizer : public Lexer
void lex(Token *token) override;
private:
PP_DISALLOW_COPY_AND_ASSIGN(Tokenizer);
bool initScanner();
void destroyScanner();
......
......@@ -27,10 +27,10 @@ IF YOU MODIFY THIS FILE YOU ALSO NEED TO RUN generate_parser.sh.
#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 @@ FRACTIONAL_CONSTANT ({DIGIT}*"."{DIGIT}+)|({DIGIT}+".")
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 @@ void Tokenizer::lex(Token *token)
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 @@ bool Tokenizer::initScanner()
void Tokenizer::destroyScanner()
{
if (mHandle == NULL)
if (mHandle == nullptr)
return;
yylex_destroy(mHandle);
mHandle = NULL;
mHandle = nullptr;
}
} // namespace pp
......
//
// 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_
......@@ -523,7 +523,7 @@ BindingInfo Program::getFragmentInputBindingInfo(GLint index) const
if (arrayIndex == GL_INVALID_INDEX)
arrayIndex = 0;
ret.name = in.mappedName + "[" + std::to_string(arrayIndex) + "]";
ret.name = in.mappedName + "[" + ToString(arrayIndex) + "]";
}
else
{
......
......@@ -577,7 +577,7 @@ void ProgramGL::postLink()
for (GLint arrayIndex = 1; arrayIndex < arraySize; ++arrayIndex)
{
PathRenderingFragmentInput arrayElementInput;
arrayElementInput.name = name + "[" + std::to_string(arrayIndex) + "]";
arrayElementInput.name = name + "[" + ToString(arrayIndex) + "]";
arrayElementInput.location = baseLocation + arrayIndex;
mPathRenderingFragmentInputs.push_back(std::move(arrayElementInput));
}
......
......@@ -564,7 +564,7 @@ TEST_P(UniformTestES3, ReturnsOnlyOneArrayElement)
for (const auto &array : uniformArrays)
{
uniformStream << "uniform " << array.type << " " << array.name << "["
<< std::to_string(kArraySize) << "];\n";
<< ToString(kArraySize) << "];\n";
// We need to make use of the uniforms or they get compiled out.
for (int i = 0; i < 4; i++)
......@@ -610,7 +610,7 @@ TEST_P(UniformTestES3, ReturnsOnlyOneArrayElement)
{
for (size_t index = 0; index < kArraySize; index++)
{
std::string strIndex = "[" + std::to_string(index) + "]";
std::string strIndex = "[" + ToString(index) + "]";
// Check all the different glGetUniformv functions
CheckOneElement<float>(glGetUniformfv, mProgram, uniformArray.name + strIndex,
uniformArray.components, 42.4242f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment