Changeset View
Changeset View
Standalone View
Standalone View
flang/lib/Semantics/mod-file.cpp
//===-- lib/Semantics/mod-file.cpp ----------------------------------------===// | //===-- lib/Semantics/mod-file.cpp ----------------------------------------===// | ||||
// | // | ||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||||
// See https://llvm.org/LICENSE.txt for license information. | // See https://llvm.org/LICENSE.txt for license information. | ||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||||
// | // | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
#include "mod-file.h" | #include "mod-file.h" | ||||
#include "resolve-names.h" | #include "resolve-names.h" | ||||
#include "flang/Common/restorer.h" | |||||
#include "flang/Evaluate/tools.h" | #include "flang/Evaluate/tools.h" | ||||
#include "flang/Parser/message.h" | #include "flang/Parser/message.h" | ||||
#include "flang/Parser/parsing.h" | #include "flang/Parser/parsing.h" | ||||
#include "flang/Semantics/scope.h" | #include "flang/Semantics/scope.h" | ||||
#include "flang/Semantics/semantics.h" | #include "flang/Semantics/semantics.h" | ||||
#include "flang/Semantics/symbol.h" | #include "flang/Semantics/symbol.h" | ||||
#include "flang/Semantics/tools.h" | #include "flang/Semantics/tools.h" | ||||
#include "llvm/Support/FileSystem.h" | #include "llvm/Support/FileSystem.h" | ||||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | private: | ||||
template <typename T> void DoExpr(evaluate::Expr<T> expr) { | template <typename T> void DoExpr(evaluate::Expr<T> expr) { | ||||
for (const Symbol &symbol : evaluate::CollectSymbols(expr)) { | for (const Symbol &symbol : evaluate::CollectSymbols(expr)) { | ||||
DoSymbol(symbol); | DoSymbol(symbol); | ||||
} | } | ||||
} | } | ||||
}; | }; | ||||
bool ModFileWriter::WriteAll() { | bool ModFileWriter::WriteAll() { | ||||
// this flag affects character literals: force it to be consistent | |||||
auto restorer{ | |||||
common::ScopedSet(parser::useHexadecimalEscapeSequences, false)}; | |||||
WriteAll(context_.globalScope()); | WriteAll(context_.globalScope()); | ||||
return !context_.AnyFatalError(); | return !context_.AnyFatalError(); | ||||
} | } | ||||
klausler: Could use `common::Restorer` here instead of a flag and a destructor. | |||||
Good idea, I've done that. tskeith: Good idea, I've done that. | |||||
void ModFileWriter::WriteAll(const Scope &scope) { | void ModFileWriter::WriteAll(const Scope &scope) { | ||||
for (const auto &child : scope.children()) { | for (const auto &child : scope.children()) { | ||||
WriteOne(child); | WriteOne(child); | ||||
} | } | ||||
} | } | ||||
void ModFileWriter::WriteOne(const Scope &scope) { | void ModFileWriter::WriteOne(const Scope &scope) { | ||||
if (scope.kind() == Scope::Kind::Module) { | if (scope.kind() == Scope::Kind::Module) { | ||||
▲ Show 20 Lines • Show All 842 Lines • Show Last 20 Lines |
Could use common::Restorer here instead of a flag and a destructor.