Commit 23866e7b by Karl Schimpf

Clean up Cl flag refrences in the bitcode parser.

The code previously had to navigate through 1 (or more) indirect pointers to find the CL flags. Since CL flags are a static field in the global context, simplify these references. Note: I have added member functions to do this (where appropriate) so that fixing code could be easy if we choose to move where the command line flags are stored. BUG=None R=eholk@chromium.org, stichnot@chromium.org Review URL: https://codereview.chromium.org/1845913003 .
parent 3dd127e6
...@@ -446,6 +446,10 @@ private: ...@@ -446,6 +446,10 @@ private:
// Defines if a module block has already been parsed. // Defines if a module block has already been parsed.
bool ParsedModuleBlock = false; bool ParsedModuleBlock = false;
static const Ice::ClFlags &getFlags() {
return Ice::GlobalContext::getFlags();
}
bool ParseBlock(unsigned BlockID) override; bool ParseBlock(unsigned BlockID) override;
// Gets extended type associated with the given index, assuming the extended // Gets extended type associated with the given index, assuming the extended
...@@ -489,8 +493,7 @@ private: ...@@ -489,8 +493,7 @@ private:
// Installs names for global variables without names. // Installs names for global variables without names.
void installGlobalVarNames() { void installGlobalVarNames() {
assert(VariableDeclarations); assert(VariableDeclarations);
const std::string &GlobalPrefix = const std::string &GlobalPrefix = getFlags().getDefaultGlobalPrefix();
getTranslator().getFlags().getDefaultGlobalPrefix();
if (!GlobalPrefix.empty()) { if (!GlobalPrefix.empty()) {
NaClBcIndexSize_t NameIndex = 0; NaClBcIndexSize_t NameIndex = 0;
for (Ice::VariableDeclaration *Var : *VariableDeclarations) { for (Ice::VariableDeclaration *Var : *VariableDeclarations) {
...@@ -501,8 +504,7 @@ private: ...@@ -501,8 +504,7 @@ private:
// Installs names for functions without names. // Installs names for functions without names.
void installFunctionNames() { void installFunctionNames() {
const std::string &FunctionPrefix = const std::string &FunctionPrefix = getFlags().getDefaultFunctionPrefix();
getTranslator().getFlags().getDefaultFunctionPrefix();
if (!FunctionPrefix.empty()) { if (!FunctionPrefix.empty()) {
NaClBcIndexSize_t NameIndex = 0; NaClBcIndexSize_t NameIndex = 0;
for (Ice::FunctionDeclaration *Func : FunctionDeclarations) { for (Ice::FunctionDeclaration *Func : FunctionDeclarations) {
...@@ -588,8 +590,7 @@ bool TopLevelParser::ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit, ...@@ -588,8 +590,7 @@ bool TopLevelParser::ErrorAt(naclbitc::ErrorLevel Level, uint64_t Bit,
NaClBitcodeParser::ErrorAt(Level, Bit, Message); NaClBitcodeParser::ErrorAt(Level, Bit, Message);
setErrStream(OldErrStream); setErrStream(OldErrStream);
} }
if (Level >= naclbitc::Error && if (Level >= naclbitc::Error && !getFlags().getAllowErrorRecovery())
!Translator.getFlags().getAllowErrorRecovery())
Fatal(); Fatal();
return true; return true;
} }
...@@ -693,7 +694,9 @@ protected: ...@@ -693,7 +694,9 @@ protected:
// Gets the translator associated with the bitcode parser. // Gets the translator associated with the bitcode parser.
Ice::Translator &getTranslator() const { return Context->getTranslator(); } Ice::Translator &getTranslator() const { return Context->getTranslator(); }
const Ice::ClFlags &getFlags() const { return getTranslator().getFlags(); } static const Ice::ClFlags &getFlags() {
return Ice::GlobalContext::getFlags();
}
// Default implementation. Reports that block is unknown and skips its // Default implementation. Reports that block is unknown and skips its
// contents. // contents.
...@@ -3176,7 +3179,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) { ...@@ -3176,7 +3179,7 @@ bool ModuleParser::ParseBlock(unsigned BlockID) {
std::unique_ptr<Ice::Cfg> Func = Parser.parseFunction(SeqNumber); std::unique_ptr<Ice::Cfg> Func = Parser.parseFunction(SeqNumber);
bool Failed = Func->hasError(); bool Failed = Func->hasError();
getTranslator().translateFcn(std::move(Func)); getTranslator().translateFcn(std::move(Func));
return Failed && !getTranslator().getFlags().getAllowErrorRecovery(); return Failed && !getFlags().getAllowErrorRecovery();
} }
} }
default: default:
......
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