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> {
|
||||
private:
|
||||
using enumSetType = EnumSet<Attr, Attr_enumSize>;
|
||||
|
||||
public:
|
||||
using enumSetType::enumSetType;
|
||||
constexpr bool HasAny(const Attrs &x) const {
|
||||
return !(*this & x).none();
|
||||
}
|
||||
constexpr bool HasAll(const Attrs &x) const {
|
||||
return (~*this & x).none();
|
||||
}
|
||||
constexpr bool HasAny(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.
|
||||
void CheckValid(const Attrs &allowed) const;
|
||||
|
||||
|
|
|
@ -14,62 +14,57 @@
|
|||
|
||||
#include "dump-parse-tree.h"
|
||||
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#include <cstdlib>
|
||||
#include <memory>
|
||||
#include <cxxabi.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Fortran::semantics {
|
||||
|
||||
std::string DemangleCxxName(const char* name) {
|
||||
std::string result;
|
||||
int status = -4; // some arbitrary value to eliminate the compiler warning
|
||||
char * output = abi::__cxa_demangle(name, NULL, NULL, &status);
|
||||
if ( status==0 ) {
|
||||
std::string DemangleCxxName(const char *name) {
|
||||
std::string result;
|
||||
int status = -4; // some arbitrary value to eliminate the compiler warning
|
||||
char *output = abi::__cxa_demangle(name, NULL, NULL, &status);
|
||||
if (status == 0) {
|
||||
std::string result(output);
|
||||
free(output) ;
|
||||
return result ;
|
||||
free(output);
|
||||
return result;
|
||||
} else {
|
||||
return name ;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
} // of namespace Fortran::semantics
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
#else
|
||||
|
||||
// Nothing if not G++
|
||||
// Nothing if not G++
|
||||
namespace Fortran::semantics {
|
||||
std::string DemangleCxxName(const char* name) {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
std::string DemangleCxxName(const char *name) { return name; }
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
#endif
|
||||
|
||||
namespace Fortran::parser {
|
||||
|
||||
bool ParseTreeDumper::startwith( const std::string str, const char *prefix) {
|
||||
size_t len = strlen(prefix) ;
|
||||
return (str.compare(0,len,prefix)==0) ;
|
||||
}
|
||||
bool ParseTreeDumper::startwith(const std::string str, const char *prefix) {
|
||||
size_t len = strlen(prefix);
|
||||
return (str.compare(0, len, prefix) == 0);
|
||||
}
|
||||
|
||||
std::string ParseTreeDumper::cleanup(const std::string &name) {
|
||||
if ( startwith(name,"Fortran::parser::") )
|
||||
return name.substr(strlen("Fortran::parser::")) ;
|
||||
if (startwith(name, "Fortran::parser::"))
|
||||
return name.substr(strlen("Fortran::parser::"));
|
||||
else
|
||||
return name;
|
||||
}
|
||||
|
||||
// Perform all required instantiations
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL()
|
||||
|
||||
} // of namespace
|
||||
|
||||
|
||||
// Perform all required instantiations
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL()
|
||||
|
||||
} // namespace Fortran::parser
|
||||
|
|
|
@ -28,42 +28,36 @@
|
|||
|
||||
namespace Fortran::semantics {
|
||||
|
||||
std::string DemangleCxxName(const char *name);
|
||||
|
||||
std::string DemangleCxxName(const char* name) ;
|
||||
|
||||
template <typename T> std::string GetTypeName_base() {
|
||||
return DemangleCxxName( typeid(T).name() ) ;
|
||||
template<typename T> std::string GetTypeName_base() {
|
||||
return DemangleCxxName(typeid(T).name());
|
||||
}
|
||||
|
||||
template <typename T> std::string GetTypeName() {
|
||||
return GetTypeName_base<
|
||||
typename std::remove_cv<
|
||||
typename std::remove_reference<
|
||||
T
|
||||
>::type
|
||||
>::type
|
||||
> ();
|
||||
}
|
||||
template<typename T> std::string GetTypeName() {
|
||||
return GetTypeName_base<
|
||||
typename std::remove_cv<typename std::remove_reference<T>::type>::type>();
|
||||
}
|
||||
|
||||
// Make it usable on
|
||||
template <typename T> std::string GetTypeName(const T &x) {
|
||||
return GetTypeName<decltype(x)>() ;
|
||||
}
|
||||
// Make it usable on
|
||||
template<typename T> std::string GetTypeName(const T &x) {
|
||||
return GetTypeName<decltype(x)>();
|
||||
}
|
||||
|
||||
// Simplify the name of some types
|
||||
|
||||
#define FLANG_PARSER_RENAME_TYPE( TYPE, NAME ) \
|
||||
template <> inline std::string GetTypeName_base<TYPE>() { return NAME; }
|
||||
// Simplify the name of some types
|
||||
|
||||
FLANG_PARSER_RENAME_TYPE( Fortran::parser::LoopBounds<Fortran::parser::ScalarIntConstantExpr> ,
|
||||
"LoopBounds<Expr>")
|
||||
#define FLANG_PARSER_RENAME_TYPE(TYPE, NAME) \
|
||||
template<> inline std::string GetTypeName_base<TYPE>() { return NAME; }
|
||||
|
||||
FLANG_PARSER_RENAME_TYPE( Fortran::parser::LoopBounds<Fortran::parser::ScalarIntExpr> ,
|
||||
"LoopBounds<Expr>")
|
||||
FLANG_PARSER_RENAME_TYPE(
|
||||
Fortran::parser::LoopBounds<Fortran::parser::ScalarIntConstantExpr>,
|
||||
"LoopBounds<Expr>")
|
||||
|
||||
FLANG_PARSER_RENAME_TYPE(
|
||||
Fortran::parser::LoopBounds<Fortran::parser::ScalarIntExpr>,
|
||||
"LoopBounds<Expr>")
|
||||
|
||||
} // end of namespace
|
||||
|
||||
} // namespace Fortran::semantics
|
||||
|
||||
namespace Fortran::parser {
|
||||
|
||||
|
@ -76,49 +70,46 @@ namespace Fortran::parser {
|
|||
class ParseTreeDumper {
|
||||
private:
|
||||
int indent;
|
||||
std::ostream &out ;
|
||||
std::ostream &out;
|
||||
bool emptyline;
|
||||
|
||||
public:
|
||||
|
||||
ParseTreeDumper(std::ostream &out_ = std::cerr) : indent(0) , out(out_) , emptyline(false) { }
|
||||
ParseTreeDumper(std::ostream &out_ = std::cerr)
|
||||
: indent(0), out(out_), emptyline(false) {}
|
||||
|
||||
private:
|
||||
|
||||
static bool startwith( const std::string str, const char *prefix) ;
|
||||
static std::string cleanup(const std::string &name) ;
|
||||
|
||||
static bool startwith(const std::string str, const char *prefix);
|
||||
static std::string cleanup(const std::string &name);
|
||||
|
||||
public:
|
||||
|
||||
void out_indent() {
|
||||
for (int i=0;i<indent;i++) {
|
||||
out << "| " ;
|
||||
for (int i = 0; i < indent; i++) {
|
||||
out << "| ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename T> bool Pre(const T &x) {
|
||||
if (emptyline ) {
|
||||
template<typename T> bool Pre(const T &x) {
|
||||
if (emptyline) {
|
||||
out_indent();
|
||||
emptyline = false ;
|
||||
emptyline = false;
|
||||
}
|
||||
if ( UnionTrait<T> || WrapperTrait<T> ) {
|
||||
out << cleanup(Fortran::semantics::GetTypeName<decltype(x)>()) << " -> " ;
|
||||
emptyline = false ;
|
||||
if (UnionTrait<T> || WrapperTrait<T>) {
|
||||
out << cleanup(Fortran::semantics::GetTypeName<decltype(x)>()) << " -> ";
|
||||
emptyline = false;
|
||||
} else {
|
||||
out << cleanup(Fortran::semantics::GetTypeName<decltype(x)>()) ;
|
||||
out << "\n" ;
|
||||
indent++ ;
|
||||
emptyline = true ;
|
||||
}
|
||||
return true ;
|
||||
out << cleanup(Fortran::semantics::GetTypeName<decltype(x)>());
|
||||
out << "\n";
|
||||
indent++;
|
||||
emptyline = true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename T> void Post(const T &x) {
|
||||
if ( UnionTrait<T> || WrapperTrait<T> ) {
|
||||
if (!emptyline) {
|
||||
out << "\n" ;
|
||||
emptyline = true ;
|
||||
|
||||
template<typename T> void Post(const T &x) {
|
||||
if (UnionTrait<T> || WrapperTrait<T>) {
|
||||
if (!emptyline) {
|
||||
out << "\n";
|
||||
emptyline = true;
|
||||
}
|
||||
} else {
|
||||
indent--;
|
||||
|
@ -141,148 +132,112 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Pre(const parser::Name &x) {
|
||||
return PutName(x.ToString(), x.symbol);
|
||||
}
|
||||
bool Pre(const parser::Name &x) { return PutName(x.ToString(), x.symbol); }
|
||||
|
||||
void Post(const parser::Name &) {
|
||||
indent--;
|
||||
}
|
||||
void Post(const parser::Name &) { indent--; }
|
||||
|
||||
bool Pre(const std::string &x) {
|
||||
return PutName(x, nullptr);
|
||||
}
|
||||
|
||||
void Post(const std::string &x) {
|
||||
indent--;
|
||||
}
|
||||
bool Pre(const std::string &x) { return PutName(x, nullptr); }
|
||||
|
||||
bool Pre(const std::int64_t &x) {
|
||||
if (emptyline ) {
|
||||
void Post(const std::string &x) { indent--; }
|
||||
|
||||
bool Pre(const std::int64_t &x) {
|
||||
if (emptyline) {
|
||||
out_indent();
|
||||
emptyline = false ;
|
||||
}
|
||||
emptyline = false;
|
||||
}
|
||||
out << "int = '" << x << "'\n";
|
||||
indent++ ;
|
||||
emptyline = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void Post(const std::int64_t &x) {
|
||||
indent--;
|
||||
indent++;
|
||||
emptyline = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Pre(const std::uint64_t &x) {
|
||||
if (emptyline ) {
|
||||
void Post(const std::int64_t &x) { indent--; }
|
||||
|
||||
bool Pre(const std::uint64_t &x) {
|
||||
if (emptyline) {
|
||||
out_indent();
|
||||
emptyline = false ;
|
||||
}
|
||||
emptyline = false;
|
||||
}
|
||||
out << "int = '" << x << "'\n";
|
||||
indent++ ;
|
||||
emptyline = true ;
|
||||
return true ;
|
||||
}
|
||||
|
||||
void Post(const std::uint64_t &x) {
|
||||
indent--;
|
||||
indent++;
|
||||
emptyline = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Post(const std::uint64_t &x) { indent--; }
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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...> &) {
|
||||
return true;
|
||||
}
|
||||
template<typename... A> bool Pre(const std::tuple<A...> &) { 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...> &) {
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename... A> void Post(const std::variant<A...> &) {
|
||||
}
|
||||
template<typename... A> bool Pre(const std::variant<A...> &) { return true; }
|
||||
|
||||
template<typename... A> void Post(const std::variant<A...> &) {}
|
||||
|
||||
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);
|
||||
Fortran::parser::Walk(x,dumper);
|
||||
Fortran::parser::Walk(x, dumper);
|
||||
}
|
||||
|
||||
|
||||
} // of namespace
|
||||
|
||||
} // namespace Fortran::parser
|
||||
|
||||
namespace Fortran::parser {
|
||||
|
||||
// Provide a explicit instantiation for a few selected node types.
|
||||
// The goal is not to provide the instanciation of all possible
|
||||
// The goal is not to provide the instanciation of all possible
|
||||
// types but to insure that a call to DumpTree will not cause
|
||||
// the instanciation of thousands of types.
|
||||
//
|
||||
|
||||
|
||||
#define FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,TYPE) \
|
||||
MODE template void Walk(const TYPE&, Fortran::parser::ParseTreeDumper &);
|
||||
#define FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, TYPE) \
|
||||
MODE template void Walk(const TYPE &, Fortran::parser::ParseTreeDumper &);
|
||||
|
||||
#define FLANG_PARSE_TREE_DUMPER_INSTANTIATE_ALL(MODE) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,ProgramUnit) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,SubroutineStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,ProgramStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,FunctionStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,ModuleStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,Expr) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,ActionStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,ExecutableConstruct) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,Block)\
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,DeclarationConstruct)\
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,SpecificationPart)\
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,OtherSpecificationStmt)\
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE,SpecificationConstruct)\
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, ProgramUnit) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, SubroutineStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, ProgramStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, FunctionStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, ModuleStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, Expr) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, ActionStmt) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, ExecutableConstruct) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, Block) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, DeclarationConstruct) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, SpecificationPart) \
|
||||
FLANG_PARSE_TREE_DUMPER_INSTANTIATE(MODE, OtherSpecificationStmt) \
|
||||
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_
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace Fortran::semantics {
|
|||
|
||||
template<typename ENUM, std::size_t BITS> class EnumSet {
|
||||
static_assert(BITS > 0);
|
||||
|
||||
public:
|
||||
using bitsetType = std::bitset<BITS>;
|
||||
using enumerationType = ENUM;
|
||||
|
@ -176,7 +177,8 @@ private:
|
|||
|
||||
template<typename ENUM, std::size_t 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());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -13,17 +13,17 @@
|
|||
// limitations under the License.
|
||||
|
||||
#include "resolve-names.h"
|
||||
#include "rewrite-parse-tree.h"
|
||||
#include "attr.h"
|
||||
#include "rewrite-parse-tree.h"
|
||||
#include "scope.h"
|
||||
#include "symbol.h"
|
||||
#include "type.h"
|
||||
#include "../parser/indirection.h"
|
||||
#include "../parser/parse-tree-visitor.h"
|
||||
#include "../parser/parse-tree.h"
|
||||
#include <ostream>
|
||||
#include <list>
|
||||
#include <memory>
|
||||
#include <ostream>
|
||||
#include <stack>
|
||||
|
||||
namespace Fortran::semantics {
|
||||
|
@ -1262,8 +1262,6 @@ static void DumpSymbols(std::ostream &os, const Scope &scope, int indent = 0) {
|
|||
--indent;
|
||||
}
|
||||
|
||||
void DumpSymbols(std::ostream &os) {
|
||||
DumpSymbols(os, Scope::globalScope);
|
||||
}
|
||||
void DumpSymbols(std::ostream &os) { DumpSymbols(os, Scope::globalScope); }
|
||||
|
||||
} // namespace Fortran::semantics
|
||||
|
|
|
@ -76,13 +76,9 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
void Post(parser::Variable &x) {
|
||||
ConvertFunctionRef(x);
|
||||
}
|
||||
void Post(parser::Variable &x) { ConvertFunctionRef(x); }
|
||||
|
||||
void Post(parser::Expr &x) {
|
||||
ConvertFunctionRef(x);
|
||||
}
|
||||
void Post(parser::Expr &x) { ConvertFunctionRef(x); }
|
||||
|
||||
private:
|
||||
const symbolMap &symbols_;
|
||||
|
@ -91,7 +87,7 @@ private:
|
|||
// For T = Variable or Expr, if x has a function reference that really
|
||||
// should be an array element reference (i.e. the name occurs in an
|
||||
// entity declaration, convert it.
|
||||
template<typename T> void ConvertFunctionRef(T & x) {
|
||||
template<typename T> void ConvertFunctionRef(T &x) {
|
||||
auto *funcRef =
|
||||
std::get_if<parser::Indirection<parser::FunctionReference>>(&x.u);
|
||||
if (!funcRef) {
|
||||
|
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
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::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) {
|
||||
os << Scope::EnumToString(scope.kind()) << " scope: " << scope.children_.size()
|
||||
<< " children\n";
|
||||
os << Scope::EnumToString(scope.kind())
|
||||
<< " scope: " << scope.children_.size() << " children\n";
|
||||
for (const auto &sym : scope.symbols_) {
|
||||
os << " " << sym.second << "\n";
|
||||
}
|
||||
|
|
|
@ -49,7 +49,10 @@ public:
|
|||
: dummyArgs_{that.dummyArgs_}, result_{that.result_} {}
|
||||
|
||||
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) {
|
||||
CHECK(!result_.has_value());
|
||||
result_ = &result;
|
||||
|
@ -91,8 +94,8 @@ public:
|
|||
Symbol(const Scope &owner, const SourceName &name, const Attrs &attrs,
|
||||
Details &&details)
|
||||
: owner_{owner}, attrs_{attrs}, details_{std::move(details)} {
|
||||
add_occurrence(name);
|
||||
}
|
||||
add_occurrence(name);
|
||||
}
|
||||
const Scope &owner() const { return owner_; }
|
||||
const SourceName &name() const { return occurrences_.front(); }
|
||||
Attrs &attrs() { return attrs_; }
|
||||
|
@ -129,12 +132,8 @@ public:
|
|||
details_.swap(details);
|
||||
}
|
||||
|
||||
const std::list<SourceName> &occurrences() const {
|
||||
return occurrences_;
|
||||
}
|
||||
void add_occurrence(const SourceName &name) {
|
||||
occurrences_.push_back(name);
|
||||
}
|
||||
const std::list<SourceName> &occurrences() const { return occurrences_; }
|
||||
void add_occurrence(const SourceName &name) { occurrences_.push_back(name); }
|
||||
|
||||
private:
|
||||
const Scope &owner_;
|
||||
|
|
|
@ -233,9 +233,10 @@ DeclTypeSpec &DeclTypeSpec::operator=(const DeclTypeSpec &that) {
|
|||
return *this;
|
||||
}
|
||||
|
||||
DeclTypeSpec::DeclTypeSpec(Category category, std::unique_ptr<DerivedTypeSpec> &&typeSpec)
|
||||
: category_{category}, intrinsicTypeSpec_{nullptr},
|
||||
derivedTypeSpec_{std::move(typeSpec)} {
|
||||
DeclTypeSpec::DeclTypeSpec(
|
||||
Category category, std::unique_ptr<DerivedTypeSpec> &&typeSpec)
|
||||
: category_{category}, intrinsicTypeSpec_{nullptr}, derivedTypeSpec_{
|
||||
std::move(typeSpec)} {
|
||||
CHECK(category == TypeDerived || category == ClassDerived);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue