forked from OSchip/llvm-project
[flang] Run clang-format on all .h and .cc files.
Original-commit: flang-compiler/f18@b7f02808a2 Reviewed-on: https://github.com/flang-compiler/f18/pull/77
This commit is contained in:
parent
7f66c0ae72
commit
b8ec1fd041
|
@ -34,14 +34,11 @@ ENUM_CLASS(Attr, ABSTRACT, ALLOCATABLE, ASYNCHRONOUS, BIND_C, CONTIGUOUS,
|
||||||
class Attrs : public EnumSet<Attr, Attr_enumSize> {
|
class Attrs : public EnumSet<Attr, Attr_enumSize> {
|
||||||
private:
|
private:
|
||||||
using enumSetType = EnumSet<Attr, Attr_enumSize>;
|
using enumSetType = EnumSet<Attr, Attr_enumSize>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using enumSetType::enumSetType;
|
using enumSetType::enumSetType;
|
||||||
constexpr bool HasAny(const Attrs &x) const {
|
constexpr bool HasAny(const Attrs &x) const { return !(*this & x).none(); }
|
||||||
return !(*this & x).none();
|
constexpr bool HasAll(const Attrs &x) const { return (~*this & x).none(); }
|
||||||
}
|
|
||||||
constexpr bool HasAll(const Attrs &x) const {
|
|
||||||
return (~*this & x).none();
|
|
||||||
}
|
|
||||||
// Internal error if any of these attributes are not in allowed.
|
// Internal error if any of these attributes are not in allowed.
|
||||||
void CheckValid(const Attrs &allowed) const;
|
void CheckValid(const Attrs &allowed) const;
|
||||||
|
|
||||||
|
|
|
@ -14,15 +14,15 @@
|
||||||
|
|
||||||
#include "dump-parse-tree.h"
|
#include "dump-parse-tree.h"
|
||||||
|
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iostream>
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
|
||||||
#include <cxxabi.h>
|
#include <cxxabi.h>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
namespace Fortran::semantics {
|
namespace Fortran::semantics {
|
||||||
|
|
||||||
|
@ -39,16 +39,14 @@ std::string DemangleCxxName(const char* name) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // of namespace Fortran::semantics
|
} // namespace Fortran::semantics
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
// Nothing if not G++
|
// Nothing if not G++
|
||||||
namespace Fortran::semantics {
|
namespace Fortran::semantics {
|
||||||
std::string DemangleCxxName(const char* name) {
|
std::string DemangleCxxName(const char *name) { return name; }
|
||||||
return name;
|
} // namespace Fortran::semantics
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -69,7 +67,4 @@ std::string ParseTreeDumper::cleanup(const std::string &name) {
|
||||||
// Perform all required instantiations
|
// Perform all required instantiations
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL()
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL()
|
||||||
|
|
||||||
} // of namespace
|
} // namespace Fortran::parser
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
|
|
||||||
namespace Fortran::semantics {
|
namespace Fortran::semantics {
|
||||||
|
|
||||||
|
|
||||||
std::string DemangleCxxName(const char *name);
|
std::string DemangleCxxName(const char *name);
|
||||||
|
|
||||||
template<typename T> std::string GetTypeName_base() {
|
template<typename T> std::string GetTypeName_base() {
|
||||||
|
@ -37,12 +36,7 @@ template <typename T> std::string GetTypeName_base() {
|
||||||
|
|
||||||
template<typename T> std::string GetTypeName() {
|
template<typename T> std::string GetTypeName() {
|
||||||
return GetTypeName_base<
|
return GetTypeName_base<
|
||||||
typename std::remove_cv<
|
typename std::remove_cv<typename std::remove_reference<T>::type>::type>();
|
||||||
typename std::remove_reference<
|
|
||||||
T
|
|
||||||
>::type
|
|
||||||
>::type
|
|
||||||
> ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make it usable on
|
// Make it usable on
|
||||||
|
@ -55,15 +49,15 @@ template <typename T> std::string GetTypeName(const T &x) {
|
||||||
#define FLANG_PARSER_RENAME_TYPE(TYPE, NAME) \
|
#define FLANG_PARSER_RENAME_TYPE(TYPE, NAME) \
|
||||||
template<> inline std::string GetTypeName_base<TYPE>() { return NAME; }
|
template<> inline std::string GetTypeName_base<TYPE>() { return NAME; }
|
||||||
|
|
||||||
FLANG_PARSER_RENAME_TYPE( Fortran::parser::LoopBounds<Fortran::parser::ScalarIntConstantExpr> ,
|
FLANG_PARSER_RENAME_TYPE(
|
||||||
|
Fortran::parser::LoopBounds<Fortran::parser::ScalarIntConstantExpr>,
|
||||||
"LoopBounds<Expr>")
|
"LoopBounds<Expr>")
|
||||||
|
|
||||||
FLANG_PARSER_RENAME_TYPE( Fortran::parser::LoopBounds<Fortran::parser::ScalarIntExpr> ,
|
FLANG_PARSER_RENAME_TYPE(
|
||||||
|
Fortran::parser::LoopBounds<Fortran::parser::ScalarIntExpr>,
|
||||||
"LoopBounds<Expr>")
|
"LoopBounds<Expr>")
|
||||||
|
|
||||||
|
} // namespace Fortran::semantics
|
||||||
} // end of namespace
|
|
||||||
|
|
||||||
|
|
||||||
namespace Fortran::parser {
|
namespace Fortran::parser {
|
||||||
|
|
||||||
|
@ -78,25 +72,22 @@ private:
|
||||||
int indent;
|
int indent;
|
||||||
std::ostream &out;
|
std::ostream &out;
|
||||||
bool emptyline;
|
bool emptyline;
|
||||||
public:
|
|
||||||
|
|
||||||
ParseTreeDumper(std::ostream &out_ = std::cerr) : indent(0) , out(out_) , emptyline(false) { }
|
public:
|
||||||
|
ParseTreeDumper(std::ostream &out_ = std::cerr)
|
||||||
|
: indent(0), out(out_), emptyline(false) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static bool startwith(const std::string str, const char *prefix);
|
static bool startwith(const std::string str, const char *prefix);
|
||||||
static std::string cleanup(const std::string &name);
|
static std::string cleanup(const std::string &name);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
void out_indent() {
|
void out_indent() {
|
||||||
for (int i = 0; i < indent; i++) {
|
for (int i = 0; i < indent; i++) {
|
||||||
out << "| ";
|
out << "| ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<typename T> bool Pre(const T &x) {
|
template<typename T> bool Pre(const T &x) {
|
||||||
if (emptyline) {
|
if (emptyline) {
|
||||||
out_indent();
|
out_indent();
|
||||||
|
@ -141,21 +132,13 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Pre(const parser::Name &x) {
|
bool Pre(const parser::Name &x) { return PutName(x.ToString(), x.symbol); }
|
||||||
return PutName(x.ToString(), x.symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Post(const parser::Name &) {
|
void Post(const parser::Name &) { indent--; }
|
||||||
indent--;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Pre(const std::string &x) {
|
bool Pre(const std::string &x) { return PutName(x, nullptr); }
|
||||||
return PutName(x, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Post(const std::string &x) {
|
void Post(const std::string &x) { indent--; }
|
||||||
indent--;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Pre(const std::int64_t &x) {
|
bool Pre(const std::int64_t &x) {
|
||||||
if (emptyline) {
|
if (emptyline) {
|
||||||
|
@ -168,9 +151,7 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Post(const std::int64_t &x) {
|
void Post(const std::int64_t &x) { indent--; }
|
||||||
indent--;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Pre(const std::uint64_t &x) {
|
bool Pre(const std::uint64_t &x) {
|
||||||
if (emptyline) {
|
if (emptyline) {
|
||||||
|
@ -183,73 +164,51 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Post(const std::uint64_t &x) {
|
void Post(const std::uint64_t &x) { indent--; }
|
||||||
indent--;
|
|
||||||
}
|
|
||||||
|
|
||||||
// A few types we want to ignore
|
// A few types we want to ignore
|
||||||
|
|
||||||
|
|
||||||
template<typename T> bool Pre(const Fortran::parser::Statement<T> &) {
|
template<typename T> bool Pre(const Fortran::parser::Statement<T> &) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void Post(const Fortran::parser::Statement<T> &) {
|
template<typename T> void Post(const Fortran::parser::Statement<T> &) {}
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> bool Pre(const Fortran::parser::Indirection<T> &) {
|
template<typename T> bool Pre(const Fortran::parser::Indirection<T> &) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void Post(const Fortran::parser::Indirection<T> &) {
|
template<typename T> void Post(const Fortran::parser::Indirection<T> &) {}
|
||||||
}
|
|
||||||
|
|
||||||
template<typename T> bool Pre(const Fortran::parser::Integer<T> &) {
|
template<typename T> bool Pre(const Fortran::parser::Integer<T> &) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void Post(const Fortran::parser::Integer<T> &) {
|
template<typename T> void Post(const Fortran::parser::Integer<T> &) {}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<typename T> bool Pre(const Fortran::parser::Scalar<T> &) {
|
template<typename T> bool Pre(const Fortran::parser::Scalar<T> &) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> void Post(const Fortran::parser::Scalar<T> &) {
|
template<typename T> void Post(const Fortran::parser::Scalar<T> &) {}
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... A> bool Pre(const std::tuple<A...> &) {
|
template<typename... A> bool Pre(const std::tuple<A...> &) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... A> void Post(const std::tuple<A...> &) {
|
template<typename... A> void Post(const std::tuple<A...> &) {}
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... A> bool Pre(const std::variant<A...> &) {
|
template<typename... A> bool Pre(const std::variant<A...> &) { return true; }
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename... A> void Post(const std::variant<A...> &) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
template<typename... A> void Post(const std::variant<A...> &) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template<typename T> void DumpTree(const T &x, std::ostream &out = std::cout) {
|
||||||
template <typename T>
|
|
||||||
void DumpTree(const T &x, std::ostream &out=std::cout )
|
|
||||||
{
|
|
||||||
ParseTreeDumper dumper(out);
|
ParseTreeDumper dumper(out);
|
||||||
Fortran::parser::Walk(x, dumper);
|
Fortran::parser::Walk(x, dumper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Fortran::parser
|
||||||
} // of namespace
|
|
||||||
|
|
||||||
|
|
||||||
namespace Fortran::parser {
|
namespace Fortran::parser {
|
||||||
|
|
||||||
|
@ -259,7 +218,6 @@ namespace Fortran::parser {
|
||||||
// the instanciation of thousands of types.
|
// the instanciation of thousands of types.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#define FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, TYPE) \
|
#define FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, TYPE) \
|
||||||
MODE template void Walk(const TYPE &, Fortran::parser::ParseTreeDumper &);
|
MODE template void Walk(const TYPE &, Fortran::parser::ParseTreeDumper &);
|
||||||
|
|
||||||
|
@ -276,13 +234,10 @@ namespace Fortran::parser {
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, DeclarationConstruct) \
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, DeclarationConstruct) \
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, SpecificationPart) \
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, SpecificationPart) \
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, OtherSpecificationStmt) \
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, OtherSpecificationStmt) \
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,SpecificationConstruct)\
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, SpecificationConstruct)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL(extern)
|
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL(extern)
|
||||||
|
|
||||||
|
|
||||||
} // of namespace
|
} // of namespace
|
||||||
|
|
||||||
#endif // FORTRAN_SEMANTICS_PARSETREEDUMP_H_
|
#endif // FORTRAN_SEMANTICS_PARSETREEDUMP_H_
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Fortran::semantics {
|
||||||
|
|
||||||
template<typename ENUM, std::size_t BITS> class EnumSet {
|
template<typename ENUM, std::size_t BITS> class EnumSet {
|
||||||
static_assert(BITS > 0);
|
static_assert(BITS > 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using bitsetType = std::bitset<BITS>;
|
using bitsetType = std::bitset<BITS>;
|
||||||
using enumerationType = ENUM;
|
using enumerationType = ENUM;
|
||||||
|
@ -176,7 +177,8 @@ private:
|
||||||
|
|
||||||
template<typename ENUM, std::size_t values>
|
template<typename ENUM, std::size_t values>
|
||||||
struct std::hash<Fortran::semantics::EnumSet<ENUM, values>> {
|
struct std::hash<Fortran::semantics::EnumSet<ENUM, values>> {
|
||||||
std::size_t operator()(const Fortran::semantics::EnumSet<ENUM, values> &x) const {
|
std::size_t operator()(
|
||||||
|
const Fortran::semantics::EnumSet<ENUM, values> &x) const {
|
||||||
return std::hash(x.bitset());
|
return std::hash(x.bitset());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -13,17 +13,17 @@
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
#include "resolve-names.h"
|
#include "resolve-names.h"
|
||||||
#include "rewrite-parse-tree.h"
|
|
||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
|
#include "rewrite-parse-tree.h"
|
||||||
#include "scope.h"
|
#include "scope.h"
|
||||||
#include "symbol.h"
|
#include "symbol.h"
|
||||||
#include "type.h"
|
#include "type.h"
|
||||||
#include "../parser/indirection.h"
|
#include "../parser/indirection.h"
|
||||||
#include "../parser/parse-tree-visitor.h"
|
#include "../parser/parse-tree-visitor.h"
|
||||||
#include "../parser/parse-tree.h"
|
#include "../parser/parse-tree.h"
|
||||||
#include <ostream>
|
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
namespace Fortran::semantics {
|
namespace Fortran::semantics {
|
||||||
|
@ -1262,8 +1262,6 @@ static void DumpSymbols(std::ostream &os, const Scope &scope, int indent = 0) {
|
||||||
--indent;
|
--indent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DumpSymbols(std::ostream &os) {
|
void DumpSymbols(std::ostream &os) { DumpSymbols(os, Scope::globalScope); }
|
||||||
DumpSymbols(os, Scope::globalScope);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace Fortran::semantics
|
} // namespace Fortran::semantics
|
||||||
|
|
|
@ -76,13 +76,9 @@ public:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Post(parser::Variable &x) {
|
void Post(parser::Variable &x) { ConvertFunctionRef(x); }
|
||||||
ConvertFunctionRef(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Post(parser::Expr &x) {
|
void Post(parser::Expr &x) { ConvertFunctionRef(x); }
|
||||||
ConvertFunctionRef(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const symbolMap &symbols_;
|
const symbolMap &symbols_;
|
||||||
|
|
|
@ -18,7 +18,8 @@
|
||||||
|
|
||||||
namespace Fortran::semantics {
|
namespace Fortran::semantics {
|
||||||
|
|
||||||
const Scope Scope::systemScope{Scope::systemScope, Scope::Kind::System, nullptr};
|
const Scope Scope::systemScope{
|
||||||
|
Scope::systemScope, Scope::Kind::System, nullptr};
|
||||||
Scope Scope::globalScope{Scope::systemScope, Scope::Kind::Global, nullptr};
|
Scope Scope::globalScope{Scope::systemScope, Scope::Kind::Global, nullptr};
|
||||||
|
|
||||||
Scope &Scope::MakeScope(Kind kind, const Symbol *symbol) {
|
Scope &Scope::MakeScope(Kind kind, const Symbol *symbol) {
|
||||||
|
@ -27,8 +28,8 @@ Scope &Scope::MakeScope(Kind kind, const Symbol *symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &os, const Scope &scope) {
|
std::ostream &operator<<(std::ostream &os, const Scope &scope) {
|
||||||
os << Scope::EnumToString(scope.kind()) << " scope: " << scope.children_.size()
|
os << Scope::EnumToString(scope.kind())
|
||||||
<< " children\n";
|
<< " scope: " << scope.children_.size() << " children\n";
|
||||||
for (const auto &sym : scope.symbols_) {
|
for (const auto &sym : scope.symbols_) {
|
||||||
os << " " << sym.second << "\n";
|
os << " " << sym.second << "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,10 @@ public:
|
||||||
: dummyArgs_{that.dummyArgs_}, result_{that.result_} {}
|
: dummyArgs_{that.dummyArgs_}, result_{that.result_} {}
|
||||||
|
|
||||||
bool isFunction() const { return result_.has_value(); }
|
bool isFunction() const { return result_.has_value(); }
|
||||||
const Symbol &result() const { CHECK(isFunction()); return **result_; }
|
const Symbol &result() const {
|
||||||
|
CHECK(isFunction());
|
||||||
|
return **result_;
|
||||||
|
}
|
||||||
void set_result(Symbol &result) {
|
void set_result(Symbol &result) {
|
||||||
CHECK(!result_.has_value());
|
CHECK(!result_.has_value());
|
||||||
result_ = &result;
|
result_ = &result;
|
||||||
|
@ -129,12 +132,8 @@ public:
|
||||||
details_.swap(details);
|
details_.swap(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::list<SourceName> &occurrences() const {
|
const std::list<SourceName> &occurrences() const { return occurrences_; }
|
||||||
return occurrences_;
|
void add_occurrence(const SourceName &name) { occurrences_.push_back(name); }
|
||||||
}
|
|
||||||
void add_occurrence(const SourceName &name) {
|
|
||||||
occurrences_.push_back(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Scope &owner_;
|
const Scope &owner_;
|
||||||
|
|
|
@ -233,9 +233,10 @@ DeclTypeSpec &DeclTypeSpec::operator=(const DeclTypeSpec &that) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
DeclTypeSpec::DeclTypeSpec(Category category, std::unique_ptr<DerivedTypeSpec> &&typeSpec)
|
DeclTypeSpec::DeclTypeSpec(
|
||||||
: category_{category}, intrinsicTypeSpec_{nullptr},
|
Category category, std::unique_ptr<DerivedTypeSpec> &&typeSpec)
|
||||||
derivedTypeSpec_{std::move(typeSpec)} {
|
: category_{category}, intrinsicTypeSpec_{nullptr}, derivedTypeSpec_{
|
||||||
|
std::move(typeSpec)} {
|
||||||
CHECK(category == TypeDerived || category == ClassDerived);
|
CHECK(category == TypeDerived || category == ClassDerived);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue