diff --git a/cpp/Makefile b/cpp/Makefile index efe16be9d3c..bbfce581f1f 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -20,6 +20,7 @@ load_first = Ice IceSSL IceBox IcePatch2Lib Glacier2Lib IceGridLib IceStormLib # projects := $(foreach t,$(wildcard $(lang_srcdir)/src/slice2*),$(eval $(call create-translator-project,$(call project,$t)))) +$(eval $(call create-translator-project,$(call project,$(lang_srcdir)/src/ice2slice))) include $(foreach p,$(load_first),src/$p/Makefile.mk) include $(filter-out $(foreach p,$(load_first),%/src/$p/Makefile.mk),$(shell find $(lang_srcdir)/src -name Makefile.mk)) $(call make-projects,$(projects),make-cpp-src-project,,$(filter all cpp,$(ICE_BIN_DIST))) diff --git a/cpp/src/Slice/FileTracker.h b/cpp/src/Slice/FileTracker.h index e9591ad54aa..0f883849e0e 100644 --- a/cpp/src/Slice/FileTracker.h +++ b/cpp/src/Slice/FileTracker.h @@ -5,8 +5,6 @@ #ifndef FILE_TRACKER_H #define FILE_TRACKER_H -#include -#include #include namespace Slice diff --git a/cpp/src/Slice/Grammar.cpp b/cpp/src/Slice/Grammar.cpp index bc702acb28f..4f731a2ab29 100644 --- a/cpp/src/Slice/Grammar.cpp +++ b/cpp/src/Slice/Grammar.cpp @@ -2499,7 +2499,7 @@ YYLTYPE yylloc = yyloc_default; else { string typeId = currentUnit->getTypeId(static_cast(id)); - if(!typeId.empty() && !currentUnit->ignRedefs()) + if(!typeId.empty()) { currentUnit->error("invalid compact id for class: already assigned to class `" + typeId + "'"); } @@ -2592,7 +2592,7 @@ YYLTYPE yylloc = yyloc_default; else { string typeId = currentUnit->getTypeId(id); - if(!typeId.empty() && !currentUnit->ignRedefs()) + if(!typeId.empty()) { currentUnit->error("invalid compact id for class: already assigned to class `" + typeId + "'"); } diff --git a/cpp/src/Slice/Grammar.y b/cpp/src/Slice/Grammar.y index 465b12d87be..ce6d1da42b5 100644 --- a/cpp/src/Slice/Grammar.y +++ b/cpp/src/Slice/Grammar.y @@ -819,7 +819,7 @@ class_id else { string typeId = currentUnit->getTypeId(static_cast(id)); - if(!typeId.empty() && !currentUnit->ignRedefs()) + if(!typeId.empty()) { currentUnit->error("invalid compact id for class: already assigned to class `" + typeId + "'"); } @@ -908,7 +908,7 @@ class_id else { string typeId = currentUnit->getTypeId(id); - if(!typeId.empty() && !currentUnit->ignRedefs()) + if(!typeId.empty()) { currentUnit->error("invalid compact id for class: already assigned to class `" + typeId + "'"); } diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp index b617b6d67d1..e6d60070dc0 100644 --- a/cpp/src/Slice/Parser.cpp +++ b/cpp/src/Slice/Parser.cpp @@ -94,10 +94,6 @@ extern int slice__flex_debug; namespace { -string readWriteAttribute[] = { "read", "write" }; -string txAttribute[] = { "supports", "mandatory", "required", "never" }; -enum { Supports, Mandatory, Required, Never }; - DataMemberList filterOrderedOptionalDataMembers(const DataMemberList& members) { @@ -300,8 +296,9 @@ Slice::DefinitionContext::initSuppressedWarnings() } else { - warning(InvalidMetaData, "", "", string("invalid category `") + s + - "' in file metadata suppress-warning"); + ostringstream os; + os << "invalid category `" << s << "' in file metadata suppress-warning"; + warning(InvalidMetaData, "", "", os.str()); } } } @@ -625,10 +622,8 @@ namespace void trimLines(StringList& l) { - // // Remove empty trailing lines. - // - while(!l.empty() && l.back().empty()) + while (!l.empty() && l.back().empty()) { l.pop_back(); } @@ -791,7 +786,7 @@ Slice::Contained::parseComment(bool stripMarkup) const if(!comment->_isDeprecated && _comment.empty()) { - return 0; + return nullptr; } // @@ -802,12 +797,12 @@ Slice::Contained::parseComment(bool stripMarkup) const StringList::const_iterator i; for(i = lines.begin(); i != lines.end(); ++i) { - const string l = *i; - if(l[0] == '@') + const string line = *i; + if(line[0] == '@') { break; } - comment->_overview.push_back(l); + comment->_overview.push_back(line); } enum State { StateMisc, StateParam, StateThrows, StateReturn, StateDeprecated }; @@ -986,13 +981,6 @@ Slice::Contained::setMetaData(const list& metaData) _metaData = metaData; } -// TODO: remove this method once "cs:" and "vb:" prefix are hard errors. -void -Slice::Contained::addMetaData(const string& s) -{ - _metaData.push_back(s); -} - FormatType Slice::Contained::parseFormatMetaData(const list& metaData) { @@ -1033,11 +1021,6 @@ Slice::Contained::Contained(const ContainerPtr& container, const string& name) : SyntaxTreeBase(container->unit()), _container(container), _name(name) -{ -} - -void -Slice::Contained::init() { ContainedPtr cont = dynamic_pointer_cast(_container); if (cont) @@ -1046,15 +1029,18 @@ Slice::Contained::init() } _scoped += "::" + _name; assert(_unit); - _unit->addContent(dynamic_pointer_cast(shared_from_this())); _file = _unit->currentFile(); - ostringstream s; - s << _unit->currentLine(); - _line = s.str(); + _line = std::to_string(_unit->currentLine()); _comment = _unit->currentComment(); _includeLevel = _unit->currentIncludeLevel(); } +void +Slice::Contained::init() +{ + _unit->addContent(dynamic_pointer_cast(shared_from_this())); +} + // ---------------------------------------------------------------------- // Container // ---------------------------------------------------------------------- @@ -1091,31 +1077,33 @@ Slice::Container::createModule(const string& name) { if (differsOnlyInCase) // Modules can be reopened only if they are capitalized correctly. { - string msg = "module `" + name + "' is capitalized inconsistently with its previous name: `"; - msg += module->name() + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "module `" << name << "' is capitalized inconsistently with its previous name: `" + << module->name() << "'"; + _unit->error(os.str()); + return nullptr; } } else if (!differsOnlyInCase) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as module"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << matches.front()->name() << "' as module"; + _unit->error(os.str()); + return nullptr; } else { - string msg = "module `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "module `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " name `" << matches.front()->name() << "'"; + _unit->error(os.str()); + return nullptr; } } - if(!checkIdentifier(name)) + if (!checkIdentifier(name)) { - return 0; + return nullptr; } ModulePtr q = make_shared(dynamic_pointer_cast(shared_from_this()), name); @@ -1142,41 +1130,39 @@ Slice::Container::createClassDef(const string& name, int id, const ClassDefPtr& { if(differsOnlyInCase) { - string msg = "class definition `" + name + "' is capitalized inconsistently with its previous name: `"; - msg += def->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "class definition `" << name << "' is capitalized inconsistently with its previous name: `" + << def->name() << "'"; + _unit->error(os.str()); } else { - if(_unit->ignRedefs()) - { - def->updateIncludeLevel(); - return def; - } - - string msg = "redefinition of class `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "redefinition of class `" << name << "'"; + _unit->error(os.str()); } } else if(differsOnlyInCase) { - string msg = "class definition `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "class definition `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " name `" << matches.front()->name() << "'"; + _unit->error(os.str()); } else { bool declared = dynamic_pointer_cast(matches.front()) != nullptr; - string msg = "class `" + name + "' was previously " + (declared ? "declared" : "defined") - + " as " + prependA(matches.front()->kindOf()); - _unit->error(msg); + ostringstream os; + os << "class `" << name << "' was previously " << (declared ? "declared" : "defined") << " as " + << prependA(matches.front()->kindOf()); + _unit->error(os.str()); } - return 0; + return nullptr; } if(!checkIdentifier(name) || !checkForGlobalDef(name, "class")) { - return 0; + return nullptr; } ClassDefPtr def = make_shared(dynamic_pointer_cast(shared_from_this()), name, id, base); @@ -1223,23 +1209,25 @@ Slice::Container::createClassDecl(const string& name) bool differsOnlyInCase = matches.front()->name() != name; if(differsOnlyInCase) { - string msg = "class declaration `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "class declaration `" << name << "' differs only in capitalization from " + << matches.front()->kindOf() << " name `" << matches.front()->name() << "'"; + _unit->error(os.str()); } else { bool declared = dynamic_pointer_cast(matches.front()) != nullptr; - string msg = "class `" + name + "' was previously " + (declared ? "declared" : "defined") - + " as " + prependA(matches.front()->kindOf()); - _unit->error(msg); + ostringstream os; + os << "class `" << name << "' was previously " << (declared ? "declared" : "defined") << " as " + << prependA(matches.front()->kindOf()); + _unit->error(os.str()); } - return 0; + return nullptr; } if(!checkIdentifier(name) || !checkForGlobalDef(name, "class")) { - return 0; + return nullptr; } // @@ -1293,42 +1281,39 @@ Slice::Container::createInterfaceDef(const string& name, const InterfaceList& ba { if(differsOnlyInCase) { - string msg = "interface definition `" + name + - "' is capitalized inconsistently with its previous name: `"; - msg += def->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "interface definition `" << name + << "' is capitalized inconsistently with its previous name: `" << def->name() + "'"; + _unit->error(os.str()); } else { - if(_unit->ignRedefs()) - { - def->updateIncludeLevel(); - return def; - } - - string msg = "redefinition of interface `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "redefinition of interface `" << name << "'"; + _unit->error(os.str()); } } else if (differsOnlyInCase) { - string msg = "interface definition `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "interface definition `" << name << "' differs only in capitalization from " + << matches.front()->kindOf() << " name `" << matches.front()->name() << "'"; + _unit->error(os.str()); } else { bool declared = dynamic_pointer_cast(matches.front()) != nullptr; - string msg = "interface `" + name + "' was previously " + (declared ? "declared" : "defined") - + " as " + prependA(matches.front()->kindOf()); - _unit->error(msg); + ostringstream os; + os << "interface `" << name << "' was previously " << (declared ? "declared" : "defined") << " as " + << prependA(matches.front()->kindOf()); + _unit->error(os.str()); } - return 0; + return nullptr; } if (!checkIdentifier(name) || !checkForGlobalDef(name, "interface")) { - return 0; + return nullptr; } InterfaceDecl::checkBasesAreLegal(name, bases, _unit); @@ -1377,23 +1362,25 @@ Slice::Container::createInterfaceDecl(const string& name) bool differsOnlyInCase = matches.front()->name() != name; if (differsOnlyInCase) { - string msg = "interface declaration `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " name `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "interface declaration `" << name << "' differs only in capitalization from " + << matches.front()->kindOf() << " name `" << matches.front()->name() << "'"; + _unit->error(os.str()); } else { bool declared = dynamic_pointer_cast(matches.front()) != nullptr; - string msg = "interface `" + name + "' was previously " + (declared ? "declared" : "defined") - + " as " + prependA(matches.front()->kindOf()); - _unit->error(msg); + ostringstream os; + os << "interface `" << name << "' was previously " << (declared ? "declared" : "defined") + << " as " << prependA(matches.front()->kindOf()); + _unit->error(os.str()); } - return 0; + return nullptr; } if (!checkIdentifier(name) || !checkForGlobalDef(name, "interface")) { - return 0; + return nullptr; } // Multiple declarations are permissible. But if we do already have a declaration for the interface in this @@ -1432,28 +1419,20 @@ Slice::Container::createException(const string& name, const ExceptionPtr& base, ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - ExceptionPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as exception"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as exception"; + _unit->error(os.str()); } else { - string msg = "exception `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "exception `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } - return 0; + return nullptr; } checkIdentifier(name); // Don't return here -- we create the exception anyway @@ -1475,28 +1454,20 @@ Slice::Container::createStruct(const string& name, NodeType nt) ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - StructPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as struct"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as struct"; + _unit->error(os.str()); } else { - string msg = "struct `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "struct `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } - return 0; + return nullptr; } checkIdentifier(name); // Don't return here -- we create the struct anyway. @@ -1518,28 +1489,20 @@ Slice::Container::createSequence(const string& name, const TypePtr& type, const ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - SequencePtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } - if(matches.front()->name() == name) + if (matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as sequence"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as sequence"; + _unit->error(os.str()); } else { - string msg = "sequence `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "sequence `" << name << "' differs only in capitalization from " << matches.front()->kindOf() << " `" + << matches.front()->name() << "'"; + _unit->error(os.str()); } - return 0; + return nullptr; } checkIdentifier(name); // Don't return here -- we create the sequence anyway. @@ -1562,28 +1525,20 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - DictionaryPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as dictionary"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as dictionary"; + _unit->error(os.str()); } else { - string msg = "dictionary `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "dictionary `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } - return 0; + return nullptr; } checkIdentifier(name); // Don't return here -- we create the dictionary anyway. @@ -1598,8 +1553,10 @@ Slice::Container::createDictionary(const string& name, const TypePtr& keyType, c bool containsSequence = false; if(!Dictionary::legalKeyType(keyType, containsSequence)) { - _unit->error("dictionary `" + name + "' uses an illegal key type"); - return 0; + ostringstream os; + os << "dictionary `" << name << "' uses an illegal key type"; + _unit->error(os.str()); + return nullptr; } if(containsSequence) { @@ -1625,28 +1582,20 @@ Slice::Container::createEnum(const string& name, NodeType nt) ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - EnumPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as enumeration"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as enumeration"; + _unit->error(os.str()); } else { - string msg = "enumeration `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "enumeration `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } - return 0; + return nullptr; } checkIdentifier(name); // Don't return here -- we create the enumeration anyway. @@ -1696,26 +1645,18 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - ConstPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as constant"; - _unit->error(msg); + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as constant"; + _unit->error(os.str()); } else { - string msg = "constant `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "constant `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } return nullptr; } @@ -1751,9 +1692,7 @@ Slice::Container::createConst(const string name, const TypePtr& constType, const TypeList Slice::Container::lookupType(const string& scoped, bool printError) { - // // Remove whitespace. - // string sc = scoped; string::size_type pos; while((pos = sc.find_first_of(" \t\r\n")) != string::npos) @@ -1761,18 +1700,14 @@ Slice::Container::lookupType(const string& scoped, bool printError) sc.erase(pos, 1); } - // // Check for builtin type. - // auto kind = Builtin::kindFromString(sc); if(kind) { return { _unit->builtin(kind.value()) }; } - // // Not a builtin type, try to look up a constructed type. - // return lookupTypeNoBuiltin(scoped, printError); } @@ -1811,10 +1746,10 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError, boo if (printError && matches.front()->scoped() != (thisScope() + sc)) { - string msg = p->kindOf() + " name `" + scoped; - msg += "' is capitalized inconsistently with its previous name: `"; - msg += matches.front()->scoped() + "'"; - errors.push_back(msg); + ostringstream os; + os << p->kindOf() << " name `" << scoped << "' is capitalized inconsistently with its previous name: `" + << matches.front()->scoped() << "'"; + errors.push_back(os.str()); } ExceptionPtr ex = dynamic_pointer_cast(p); @@ -1822,10 +1757,9 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError, boo { if (printError) { - string msg = "`"; - msg += sc; - msg += "' is an exception, which cannot be used as a type"; - _unit->error(msg); + ostringstream os; + os << "`" << sc << "' is an exception, which cannot be used as a type"; + _unit->error(os.str()); } return TypeList(); } @@ -1836,10 +1770,9 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError, boo typeError = true; if (printError) { - string msg = "`"; - msg += sc; - msg += "' is not a type"; - errors.push_back(msg); + ostringstream os; + os << "`" << sc << "' is not a type"; + errors.push_back(os.str()); } break; // Possible that correct match is higher in scope } @@ -1857,10 +1790,9 @@ Slice::Container::lookupTypeNoBuiltin(const string& scoped, bool printError, boo { if(printError && !ignoreUndefined) { - string msg = "`"; - msg += sc; - msg += "' is not defined"; - _unit->error(msg); + ostringstream os; + os << "`" << sc << "' is not defined"; + _unit->error(os.str()); } return TypeList(); } @@ -1907,9 +1839,10 @@ Slice::Container::lookupContained(const string& scoped, bool printError) if (printError && p->scoped() != (thisScope() + sc)) { - string msg = p->kindOf() + " name `" + scoped; - msg += "' is capitalized inconsistently with its previous name: `" + p->scoped() + "'"; - _unit->error(msg); + ostringstream os; + os << p->kindOf() << " name `" << scoped << "' is capitalized inconsistently with its previous name: `" + << p->scoped() << "'"; + _unit->error(os.str()); } } @@ -1920,10 +1853,9 @@ Slice::Container::lookupContained(const string& scoped, bool printError) { if(printError) { - string msg = "`"; - msg += sc; - msg += "' is not defined"; - _unit->error(msg); + ostringstream os; + os << "`" << sc << "' is not defined"; + _unit->error(os.str()); } return ContainedList(); } @@ -1941,7 +1873,7 @@ Slice::Container::lookupException(const string& scoped, bool printError) ContainedList contained = lookupContained(scoped, printError); if(contained.empty()) { - return 0; + return nullptr; } ExceptionList exceptions; @@ -1952,12 +1884,11 @@ Slice::Container::lookupException(const string& scoped, bool printError) { if(printError) { - string msg = "`"; - msg += scoped; - msg += "' is not an exception"; - _unit->error(msg); + ostringstream os; + os << "`" << scoped << "' is not an exception"; + _unit->error(os.str()); } - return 0; + return nullptr; } exceptions.push_back(ex); } @@ -1990,6 +1921,7 @@ ClassList Slice::Container::classes() const { ClassList result; + for (const auto& p : _contents) { ClassDefPtr q = dynamic_pointer_cast(p); @@ -2149,9 +2081,9 @@ Slice::Container::enumerators(const string& scoped) const { EnumList enums = container->enums(); string name = scoped.substr(lastColon + 1); - for(EnumList::iterator p = enums.begin(); p != enums.end(); ++p) + for (const auto& p : enums) { - ContainedList cl2 = (*p)->lookupContained(name, false); + ContainedList cl2 = p->lookupContained(name, false); if(!cl2.empty()) { result.push_back(dynamic_pointer_cast(cl2.front())); @@ -2363,57 +2295,6 @@ Slice::Container::hasValueDefs() const return false; } -bool -Slice::Container::hasOnlyClassDecls() const -{ - for (const auto& p : _contents) - { - ModulePtr m = dynamic_pointer_cast(p); - if(m) - { - if(!m->hasOnlyClassDecls()) - { - return false; - } - } - else if(!dynamic_pointer_cast(p)) - { - return false; - } - } - - return true; -} - -bool -Slice::Container::hasOnlyInterfaces() const -{ - for (const auto& p : _contents) - { - ModulePtr m = dynamic_pointer_cast(p); - if (m) - { - if (!m->hasOnlyInterfaces()) - { - return false; - } - } - else - { - InterfaceDeclPtr decl = dynamic_pointer_cast(p); - if (!decl) - { - InterfaceDefPtr def = dynamic_pointer_cast(p); - if (!def) - { - return false; - } - } - } - } - return true; -} - bool Slice::Container::hasOperations() const { @@ -2553,71 +2434,6 @@ Slice::Container::thisScope() const return s; } -void -Slice::Container::mergeModules() -{ - for (ContainedList::iterator p = _contents.begin(); p != _contents.end(); ++p) - { - ModulePtr mod1 = dynamic_pointer_cast(*p); - if(!mod1) - { - continue; - } - - DefinitionContextPtr dc1 = mod1->definitionContext(); - assert(dc1); - StringList metaData1 = dc1->getMetaData(); - metaData1.sort(); - metaData1.unique(); - - ContainedList::iterator q = p; - ++q; - while(q != _contents.end()) - { - ModulePtr mod2 = dynamic_pointer_cast(*q); - if(!mod2) - { - ++q; - continue; - } - - if(mod1->name() != mod2->name()) - { - ++q; - continue; - } - - // - // Compare the file metadata of the two modules being merged. - // - DefinitionContextPtr dc2 = mod2->definitionContext(); - assert(dc2); - StringList metaData2 = dc2->getMetaData(); - metaData2.sort(); - metaData2.unique(); - if(!checkGlobalMetaData(metaData1, metaData2)) - { - unit()->warning(All, "file metadata mismatch for module `" + mod1->name() + "' in files " + - dc1->filename() + " and " + dc2->filename()); - } - - mod1->_contents.splice(mod1->_contents.end(), mod2->_contents); - - if(mod1->_comment.length() < mod2->_comment.length()) - { - mod1->_comment.swap(mod2->_comment); - } - - mod1->_includeLevel = min(mod1->_includeLevel, mod2->_includeLevel); - - _unit->removeContent(*q); - q = _contents.erase(q); - } - - mod1->mergeModules(); - } -} - void Slice::Container::sort() { @@ -2665,20 +2481,6 @@ Slice::Container::visit(ParserVisitor* visitor, bool all) } } -void -Slice::Container::containerRecDependencies(ConstructedSet& dependencies) -{ - for (const auto& p : _contents) - { - ConstructedPtr constructed = dynamic_pointer_cast(p); - if(constructed && dependencies.find(constructed) != dependencies.end()) - { - dependencies.insert(constructed); - constructed->recDependencies(dependencies); - } - } -} - bool Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing) { @@ -2687,17 +2489,12 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing) return true; } - // // Split off first component. - // string::size_type pos = scoped.find("::"); string firstComponent = pos == string::npos ? scoped : scoped.substr(0, pos); - // - // If we don't have a type, the thing that is introduced is the contained for - // the first component. - // - if(namedThing == 0) + // If we don't have a type, the thing that is introduced is the contained for the first component. + if(namedThing == nullptr) { ContainedList cl = lookupContained(firstComponent, false); if(cl.empty()) @@ -2708,10 +2505,8 @@ Slice::Container::checkIntroduced(const string& scoped, ContainedPtr namedThing) } else { - // - // For each scope, get the container until we have the container - // for the first scope (which is the introduced one). - // + // For each scope, get the container until we have the container for the first scope (which is the introduced + // one). ContainerPtr c; bool first = true; while(pos != string::npos) @@ -2780,7 +2575,9 @@ Slice::Container::checkForGlobalDef(const string& name, const char* newConstruct { if(dynamic_cast(this) && strcmp(newConstruct, "module")) { - _unit->error("`" + name + "': " + prependA(newConstruct) + " can be defined only at module scope"); + ostringstream os; + os << "`" << name << "': " << prependA(newConstruct) << " can be defined only at module scope"; + _unit->error(os.str()); return false; } return true; @@ -2791,38 +2588,6 @@ Slice::Container::Container(const UnitPtr& unit) : { } -bool -Slice::Container::checkGlobalMetaData(const StringList& m1, const StringList& m2) -{ - // - // Not all file metadata mismatches represent actual problems. We are only concerned about - // the prefixes listed below (also see bug 2766). - // - static const char* prefixes[] = - { - "java:package", - "python:package", - 0 - }; - - // Collect the metadata that is unique to each list. - StringList diffs; - set_symmetric_difference(m1.begin(), m1.end(), m2.begin(), m2.end(), back_inserter(diffs)); - - for(StringList::const_iterator p = diffs.begin(); p != diffs.end(); ++p) - { - for(int i = 0; prefixes[i] != 0; ++i) - { - if(p->find(prefixes[i]) != string::npos) - { - return false; - } - } - } - - return true; -} - bool Slice::Container::validateConstant(const string& name, const TypePtr& type, SyntaxTreeBasePtr& valueType, const string& value, bool isConstant) @@ -2849,12 +2614,16 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt { if(isConstant) { - _unit->error("constant `" + name + "' has illegal type: `" + b->kindAsString() + "'"); + ostringstream os; + os << "constant `" << name << "' has illegal type: `" << b->kindAsString() << "'"; + _unit->error(os.str()); } else { - _unit->error("default value not allowed for data member `" + name + "' of type `" + - b->kindAsString() + "'"); + ostringstream os; + os << "default value not allowed for data member `" << name << "' of type `" << b->kindAsString() + << "'"; + _unit->error(os.str()); } return false; } @@ -2863,11 +2632,15 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt { if(isConstant) { - _unit->error("constant `" + name + "' has illegal type"); + ostringstream os; + os << "constant `" << name << "' has illegal type"; + _unit->error(os.str()); } else { - _unit->error("default value not allowed for data member `" + name + "'"); + ostringstream os; + os << "default value not allowed for data member `" << name << "'"; + _unit->error(os.str()); } return false; } @@ -2904,17 +2677,18 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt if(!ok) { - string msg = "initializer of type `" + lt->kindAsString() + "' is incompatible with the type `" + - b->kindAsString() + "' of " + desc + " `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "initializer of type `" << lt->kindAsString() << "' is incompatible with the type `" << b->kindAsString() + << "' of " << desc << " `" << name << "'"; + _unit->error(os.str()); return false; } } else { - string msg = "type of initializer is incompatible with the type `" + b->kindAsString() + "' of " + desc + - " `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "type of initializer is incompatible with the type `" << b->kindAsString() << "' of " << desc << " `" << name << "'"; + _unit->error(os.str()); return false; } @@ -2925,9 +2699,10 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt IceUtil::Int64 l = IceUtilInternal::strToInt64(value.c_str(), 0, 0); if(l < ByteMin || l > ByteMax) { - string msg = "initializer `" + value + "' for " + desc + " `" + name + - "' out of range for type byte"; - _unit->error(msg); + ostringstream os; + os << "initializer `" << value << "' for " << desc << " `" << name + << "' out of range for type byte"; + _unit->error(os.str()); return false; } break; @@ -2937,9 +2712,10 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt IceUtil::Int64 l = IceUtilInternal::strToInt64(value.c_str(), 0, 0); if(l < Int16Min || l > Int16Max) { - string msg = "initializer `" + value + "' for " + desc + " `" + name + - "' out of range for type short"; - _unit->error(msg); + ostringstream os; + os << "initializer `" << value << "' for " << desc << " `" << name + << "' out of range for type short"; + _unit->error(os.str()); return false; } break; @@ -2949,9 +2725,10 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt IceUtil::Int64 l = IceUtilInternal::strToInt64(value.c_str(), 0, 0); if(l < Int32Min || l > Int32Max) { - string msg = "initializer `" + value + "' for " + desc + " `" + name + - "' out of range for type int"; - _unit->error(msg); + ostringstream os; + os << "initializer `" << value << "' for " + desc << " `" << name + << "' out of range for type int"; + _unit->error(os.str()); return false; } break; @@ -2971,8 +2748,9 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt EnumPtr ec = dynamic_pointer_cast(constant->type()); if(e != ec) { - string msg = "type of initializer is incompatible with the type of " + desc + " `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "type of initializer is incompatible with the type of " << desc << " `" << name << "'"; + _unit->error(os.str()); return false; } } @@ -2984,15 +2762,17 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt if(!lte) { - string msg = "type of initializer is incompatible with the type of " + desc + " `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "type of initializer is incompatible with the type of " << desc << " `" << name << "'"; + _unit->error(os.str()); return false; } EnumeratorList elist = e->enumerators(); if(find(elist.begin(), elist.end(), lte) == elist.end()) { - string msg = "enumerator `" + value + "' is not defined in enumeration `" + e->scoped() + "'"; - _unit->error(msg); + ostringstream os; + os << "enumerator `" << value << "' is not defined in enumeration `" << e->scoped() << "'"; + _unit->error(os.str()); return false; } } @@ -3009,24 +2789,29 @@ Slice::Container::validateConstant(const string& name, const TypePtr& type, Synt ContainedList clist = e->lookupContained(newVal, false); if(clist.empty()) { - string msg = "`" + value + "' does not designate an enumerator of `" + e->scoped() + "'"; - _unit->error(msg); + ostringstream os; + os << "`" << value << "' does not designate an enumerator of `" << e->scoped() << "'"; + _unit->error(os.str()); return false; } + EnumeratorPtr lte = dynamic_pointer_cast(clist.front()); if(lte) { valueType = lte; if(lastColon != string::npos) { - _unit->warning(Deprecated, string("referencing enumerator `") + lte->name() + - "' in its enumeration's enclosing scope is deprecated"); + ostringstream os; + os << "referencing enumerator `" << lte->name() + << "' in its enumeration's enclosing scope is deprecated"; + _unit->warning(Deprecated, os.str()); } } else { - string msg = "type of initializer is incompatible with the type of " + desc + " `" + name + "'"; - _unit->error(msg); + ostringstream os; + os << "type of initializer is incompatible with the type of " << desc << " `" << name << "'"; + _unit->error(os.str()); return false; } } @@ -3043,28 +2828,23 @@ Slice::Container::validateEnumerator(const string& name) if(!matches.empty()) { EnumeratorPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() == name) { - _unit->error(string("redefinition of enumerator `") + name + "'"); + ostringstream os; + os << "redefinition of enumerator `" << name << "'"; + _unit->error(os.str()); } else { - string msg = "enumerator `" + name + "' differs only in capitalization from "; - msg += "`" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "enumerator `" << name << "' differs only in capitalization from `" << matches.front()->name() + << "'"; + _unit->error(os.str()); } } checkIdentifier(name); // Ignore return value. - return 0; + return nullptr; } // ---------------------------------------------------------------------- @@ -3077,12 +2857,6 @@ Slice::Module::containedType() const return ContainedTypeModule; } -bool -Slice::Module::uses(const ContainedPtr&) const -{ - return false; -} - string Slice::Module::kindOf() const { @@ -3117,15 +2891,6 @@ Slice::Constructed::typeId() const return scoped(); } -ConstructedList -Slice::Constructed::dependencies() -{ - ConstructedSet resultSet(containedCompare); - recDependencies(resultSet); - - return ConstructedList(resultSet.begin(), resultSet.end()); -} - Slice::Constructed::Constructed(const ContainerPtr& container, const string& name) : SyntaxTreeBase(container->unit()), Type(container->unit()), @@ -3156,12 +2921,6 @@ Slice::ClassDecl::containedType() const return ContainedTypeClass; } -bool -Slice::ClassDecl::uses(const ContainedPtr&) const -{ - return false; -} - bool Slice::ClassDecl::usesClasses() const { @@ -3198,20 +2957,6 @@ Slice::ClassDecl::visit(ParserVisitor* visitor, bool) visitor->visitClassDecl(dynamic_pointer_cast(shared_from_this())); } -void -Slice::ClassDecl::recDependencies(ConstructedSet& dependencies) -{ - if(_definition) - { - _definition->containerRecDependencies(dependencies); - ClassDefPtr base = _definition->base(); - if (base) - { - base->declaration()->recDependencies(dependencies); - } - } -} - Slice::ClassDecl::ClassDecl(const ContainerPtr& container, const string& name) : SyntaxTreeBase(container->unit()), Type(container->unit()), @@ -3241,28 +2986,20 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - DataMemberPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } - if(matches.front()->name() != name) { - string msg = "data member `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "data member `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } else { - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as data member `" + name + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << name << "' as data member `" << name + << "'"; + _unit->error(os.str()); + return nullptr; } } @@ -3277,19 +3014,20 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool { if(dataMember->name() == name) { - string msg = "data member `" + name; - msg += "' is already defined as a data member in a base class"; - _unit->error(msg); - return 0; + ostringstream os; + os << "data member `" << name << "' is already defined as a data member in a base class"; + _unit->error(os.str()); + return nullptr; } string baseName = IceUtilInternal::toLower(dataMember->name()); string newName = IceUtilInternal::toLower(name); if(baseName == newName) { - string msg = "data member `" + name + "' differs only in capitalization from data member"; - msg += " `" + dataMember->name() + "', which is defined in a base class"; - _unit->error(msg); + ostringstream os; + os << "data member `" << name << "' differs only in capitalization from data member `" + << dataMember->name() << "', which is defined in a base class"; + _unit->error(os.str()); } } } @@ -3317,8 +3055,9 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type, bool { if (q->optional() && tag == q->tag()) { - string msg = "tag for optional data member `" + name + "' is already in use"; - _unit->error(msg); + ostringstream os; + os << "tag for optional data member `" << name << "' is already in use"; + _unit->error(os.str()); break; } } @@ -3494,12 +3233,6 @@ Slice::ClassDef::containedType() const return ContainedTypeClass; } -bool -Slice::ClassDef::uses(const ContainedPtr&) const -{ - // No uses() implementation here. DataMember and Operation have their own uses(). - return false; -} string Slice::ClassDef::kindOf() const { @@ -3560,12 +3293,6 @@ Slice::InterfaceDecl::containedType() const return ContainedTypeInterface; } -bool -Slice::InterfaceDecl::uses(const ContainedPtr&) const -{ - return false; -} - bool Slice::InterfaceDecl::usesClasses() const { @@ -3602,19 +3329,6 @@ Slice::InterfaceDecl::visit(ParserVisitor* visitor, bool) visitor->visitInterfaceDecl(dynamic_pointer_cast(shared_from_this())); } -void -Slice::InterfaceDecl::recDependencies(ConstructedSet& dependencies) -{ - if (_definition) - { - _definition->containerRecDependencies(dependencies); - for (const auto& p : _definition->bases()) - { - p->declaration()->recDependencies(dependencies); - } - } -} - void Slice::InterfaceDecl::checkBasesAreLegal( const string& name, @@ -3768,18 +3482,20 @@ Slice::InterfaceDecl::checkPairIntersections(const StringPartitionList& l, const { if((*s1) == (*s2) && reported.find(*s1) == reported.end()) { - string msg = "ambiguous multiple inheritance: `" + name; - msg += "' inherits operation `" + *s1 + "' from two or more unrelated base interfaces"; - ut->error(msg); + ostringstream os; + os << "ambiguous multiple inheritance: `" << name << "' inherits operation `" << (*s1) + << "' from two or more unrelated base interfaces"; + ut->error(os.str()); reported.insert(*s1); } else if(!CICompare()(*s1, *s2) && !CICompare()(*s2, *s1) && reported.find(*s1) == reported.end() && reported.find(*s2) == reported.end()) { - string msg = "ambiguous multiple inheritance: `" + name; - msg += "' inherits operations `" + *s1 + "' and `" + *s2; - msg += "', which differ only in capitalization, from unrelated base interfaces"; - ut->error(msg); + ostringstream os; + os << "ambiguous multiple inheritance: `" << name << "' inherits operations `" + << (*s1) << "' and `" << (*s2) + << "', which differ only in capitalization, from unrelated base interfaces"; + ut->error(os.str()); reported.insert(*s1); reported.insert(*s2); } @@ -3812,43 +3528,38 @@ Slice::InterfaceDef::createOperation( ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - OperationPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() != name) { - string msg = "operation `" + name + "' differs only in capitalization from "; - msg += matches.front()->kindOf() + " `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "operation `" << name << "' differs only in capitalization from " << matches.front()->kindOf() + << " `" << matches.front()->name() << "'"; + _unit->error(os.str()); } - string msg = "redefinition of " + matches.front()->kindOf() + " `" + matches.front()->name(); - msg += "' as operation `" + name + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of " << matches.front()->kindOf() << " `" << matches.front()->name() << "' as operation `" + << name << "'"; + _unit->error(os.str()); + return nullptr; } // Check whether enclosing interface has the same name. if(name == this->name()) { - string msg = "interface name `" + name + "' cannot be used as operation name"; - _unit->error(msg); - return 0; + ostringstream os; + os << "interface name `" << name << "' cannot be used as operation name"; + _unit->error(os.str()); + return nullptr; } string newName = IceUtilInternal::toLower(name); string thisName = IceUtilInternal::toLower(this->name()); if(newName == thisName) { - string msg = "operation `" + name + "' differs only in capitalization from enclosing "; - msg += "interface name `" + this->name() + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "operation `" << name << "' differs only in capitalization from enclosing interface name `" + << this->name() << "'"; + _unit->error(os.str()); + return nullptr; } // Check whether any base has an operation with the same name already @@ -3858,19 +3569,21 @@ Slice::InterfaceDef::createOperation( { if(op->name() == name) { - string msg = "operation `" + name + "' is already defined as an operation in a base interface"; - _unit->error(msg); - return 0; + ostringstream os; + os << "operation `" << name << "' is already defined as an operation in a base interface"; + _unit->error(os.str()); + return nullptr; } string baseName = IceUtilInternal::toLower(op->name()); string newName2 = IceUtilInternal::toLower(name); if(baseName == newName2) { - string msg = "operation `" + name + "' differs only in capitalization from operation"; - msg += " `" + op->name() + "', which is defined in a base interface"; - _unit->error(msg); - return 0; + ostringstream os; + os << "operation `" << name << "' differs only in capitalization from operation" + << " `" << op->name() << "', which is defined in a base interface"; + _unit->error(os.str()); + return nullptr; } } } @@ -4003,13 +3716,6 @@ Slice::InterfaceDef::containedType() const return ContainedTypeInterface; } -bool -Slice::InterfaceDef::uses(const ContainedPtr&) const -{ - // No uses() implementation here. - return false; -} - string Slice::InterfaceDef::kindOf() const { @@ -4070,33 +3776,24 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type, bool ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - DataMemberPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() != name) { - string msg = "exception member `" + name + "' differs only in capitalization from "; - msg += "exception member `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "exception member `" << name << "' differs only in capitalization from exception member `" + << matches.front()->name() << "'"; + _unit->error(os.str()); } else { - string msg = "redefinition of exception member `" + name + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of exception member `" << name << "'"; + _unit->error(os.str()); + return nullptr; } } checkIdentifier(name); // Don't return here -- we create the data member anyway. - string newName = IceUtilInternal::toLower(name); - // Check whether any bases have defined a member with the same name already. ExceptionList bl = allBases(); for (const auto& q : allBases()) @@ -4109,18 +3806,20 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type, bool { if (r->name() == name) { - string msg = "exception member `" + name + "' is already defined in a base exception"; - _unit->error(msg); - return 0; + ostringstream os; + os << "exception member `" << name << "' is already defined in a base exception"; + _unit->error(os.str()); + return nullptr; } string baseName = IceUtilInternal::toLower(r->name()); - string newName2 = IceUtilInternal::toLower(name); - if(baseName == newName2) + string newName = IceUtilInternal::toLower(name); + if(baseName == newName) // TOOD use ciCompare { - string msg = "exception member `" + name + "' differs only in capitalization from exception member `"; - msg += r->name() + "', which is defined in a base exception"; - _unit->error(msg); + ostringstream os; + os << "exception member `" << name << "' differs only in capitalization from exception member `" + << r->name() << "', which is defined in a base exception"; + _unit->error(os.str()); } } } @@ -4148,8 +3847,9 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type, bool { if(q->optional() && tag == q->tag()) { - string msg = "tag for optional data member `" + name + "' is already in use"; - _unit->error(msg); + ostringstream os; + os << "tag for optional data member `" << name << "' is already in use"; + _unit->error(os.str()); break; } } @@ -4266,14 +3966,15 @@ Slice::Exception::allBases() const bool Slice::Exception::isBaseOf(const ExceptionPtr& other) const { - if(this->scoped() == other->scoped()) + string scope = scoped(); + if(scope == other->scoped()) { return false; } for (const auto& i : other->allBases()) { - if (i->scoped() == scoped()) + if (i->scoped() == scope) { return true; } @@ -4287,13 +3988,6 @@ Slice::Exception::containedType() const return ContainedTypeException; } -bool -Slice::Exception::uses(const ContainedPtr&) const -{ - // No uses() implementation here. DataMember has its own uses(). - return false; -} - bool Slice::Exception::usesClasses(bool includeOptional) const { @@ -4380,26 +4074,19 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type, bool op ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - DataMemberPtr p = dynamic_pointer_cast(matches.front()); - if(p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() != name) { - string msg = "member `" + name + "' differs only in capitalization from "; - msg += "member `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "member `" << name << "' differs only in capitalization from member `" << matches.front()->name() + << "'"; + _unit->error(os.str()); } else { - string msg = "redefinition of struct member `" + name + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of struct member `" << name << "'"; + _unit->error(os.str()); + return nullptr; } } @@ -4408,11 +4095,10 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type, bool op // Structures cannot contain themselves. if(type.get() == this) { - string msg = "struct `"; - msg += this->name(); - msg += "' cannot contain itself"; - _unit->error(msg); - return 0; + ostringstream os; + os << "struct `" << this->name() << "' cannot contain itself"; + _unit->error(os.str()); + return nullptr; } SyntaxTreeBasePtr dlt = defaultValueType; @@ -4491,12 +4177,6 @@ Slice::Struct::containedType() const return ContainedTypeStruct; } -bool -Slice::Struct::uses(const ContainedPtr&) const -{ - return false; -} - bool Slice::Struct::usesClasses() const { @@ -4570,12 +4250,6 @@ Slice::Struct::visit(ParserVisitor* visitor, bool all) } } -void -Slice::Struct::recDependencies(ConstructedSet& dependencies) -{ - containerRecDependencies(dependencies); -} - Slice::Struct::Struct(const ContainerPtr& container, const string& name) : SyntaxTreeBase(container->unit()), Container(container->unit()), @@ -4607,18 +4281,6 @@ Slice::Sequence::containedType() const return ContainedTypeSequence; } -bool -Slice::Sequence::uses(const ContainedPtr& contained) const -{ - ContainedPtr contained2 = dynamic_pointer_cast(_type); - if (contained2 && contained2->scoped() == contained->scoped()) - { - return true; - } - - return false; -} - bool Slice::Sequence::usesClasses() const { @@ -4655,17 +4317,6 @@ Slice::Sequence::visit(ParserVisitor* visitor, bool) visitor->visitSequence(dynamic_pointer_cast(shared_from_this())); } -void -Slice::Sequence::recDependencies(ConstructedSet& dependencies) -{ - ConstructedPtr constructed = dynamic_pointer_cast(_type); - if(constructed && dependencies.find(constructed) != dependencies.end()) - { - dependencies.insert(constructed); - constructed->recDependencies(dependencies); - } -} - Slice::Sequence::Sequence(const ContainerPtr& container, const string& name, const TypePtr& type, const StringList& typeMetaData) : SyntaxTreeBase(container->unit()), @@ -4711,28 +4362,6 @@ Slice::Dictionary::containedType() const return ContainedTypeDictionary; } -bool -Slice::Dictionary::uses(const ContainedPtr& contained) const -{ - { - ContainedPtr contained2 = dynamic_pointer_cast(_keyType); - if(contained2 && contained2->scoped() == contained->scoped()) - { - return true; - } - } - - { - ContainedPtr contained2 = dynamic_pointer_cast(_valueType); - if(contained2 && contained2->scoped() == contained->scoped()) - { - return true; - } - } - - return false; -} - bool Slice::Dictionary::usesClasses() const { @@ -4769,28 +4398,6 @@ Slice::Dictionary::visit(ParserVisitor* visitor, bool) visitor->visitDictionary(dynamic_pointer_cast(shared_from_this())); } -void -Slice::Dictionary::recDependencies(ConstructedSet& dependencies) -{ - { - ConstructedPtr constructed = dynamic_pointer_cast(_keyType); - if(constructed && dependencies.find(constructed) != dependencies.end()) - { - dependencies.insert(constructed); - constructed->recDependencies(dependencies); - } - } - - { - ConstructedPtr constructed = dynamic_pointer_cast(_valueType); - if(constructed && dependencies.find(constructed) != dependencies.end()) - { - dependencies.insert(constructed); - constructed->recDependencies(dependencies); - } - } -} - // Check that the key type of a dictionary is legal. Legal types are integral types, string, and sequences and structs // containing only other legal key types. // @@ -4906,12 +4513,6 @@ Slice::Enum::containedType() const return ContainedTypeEnum; } -bool -Slice::Enum::uses(const ContainedPtr&) const -{ - return false; -} - bool Slice::Enum::usesClasses() const { @@ -4948,12 +4549,6 @@ Slice::Enum::visit(ParserVisitor* visitor, bool) visitor->visitEnum(dynamic_pointer_cast(Container::shared_from_this())); } -void -Slice::Enum::recDependencies(ConstructedSet&) -{ - // An Enum does not have any dependencies. -} - Slice::Enum::Enum(const ContainerPtr& container, const string& name) : SyntaxTreeBase(container->unit()), Container(container->unit()), @@ -4977,16 +4572,18 @@ Slice::Enum::newEnumerator(const EnumeratorPtr& p) if(_lastValue < 0) { - string msg = "value for enumerator `" + p->name() + "' is out of range"; - _unit->error(msg); + ostringstream os; + os << "value for enumerator `" << p->name() << "' is out of range"; + _unit->error(os.str()); } } else { if(_lastValue == Int32Max) { - string msg = "value for enumerator `" + p->name() + "' is out of range"; - _unit->error(msg); + ostringstream os; + os << "value for enumerator `" << p->name() << "' is out of range"; + _unit->error(os.str()); } else { @@ -5042,12 +4639,6 @@ Slice::Enumerator::containedType() const return ContainedTypeEnumerator; } -bool -Slice::Enumerator::uses(const ContainedPtr&) const -{ - return false; -} - string Slice::Enumerator::kindOf() const { @@ -5133,13 +4724,6 @@ Slice::Const::containedType() const return ContainedTypeConstant; } -bool -Slice::Const::uses(const ContainedPtr& contained) const -{ - ContainedPtr contained2 = dynamic_pointer_cast(_type); - return (contained2 && contained2 == contained); -} - string Slice::Const::kindOf() const { @@ -5163,11 +4747,6 @@ Slice::Const::Const(const ContainerPtr& container, const string& name, const Typ _value(value), _literal(literal) { - if(valueType == 0) - { - cerr << "const " << name << " created with null valueType" << endl; - } - } // ---------------------------------------------------------------------- @@ -5247,26 +4826,19 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool ContainedList matches = _unit->findContents(thisScope() + name); if(!matches.empty()) { - ParamDeclPtr p = dynamic_pointer_cast(matches.front()); - if (p) - { - if(_unit->ignRedefs()) - { - p->updateIncludeLevel(); - return p; - } - } if(matches.front()->name() != name) { - string msg = "parameter `" + name + "' differs only in capitalization from "; - msg += "parameter `" + matches.front()->name() + "'"; - _unit->error(msg); + ostringstream os; + os << "parameter `" << name << "' differs only in capitalization from parameter `" + << matches.front()->name() << "'"; + _unit->error(os.str()); } else { - string msg = "redefinition of parameter `" + name + "'"; - _unit->error(msg); - return 0; + ostringstream os; + os << "redefinition of parameter `" << name << "'"; + _unit->error(os.str()); + return nullptr; } } @@ -5281,28 +4853,28 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool assert(p); if(p->isOutParam() && !isOutParam) { - _unit->error("`" + name + "': in parameters cannot follow out parameters"); + ostringstream os; + os << "`" << name << "': in parameters cannot follow out parameters"; + _unit->error(os.str()); } } if(optional) { - // // Check for a duplicate tag. - // - const string msg = "tag for optional parameter `" + name + "' is already in use"; + ostringstream os; + os << "tag for optional parameter `" << name << "' is already in use"; if(_returnIsOptional && tag == _returnTag) { - _unit->error(msg); + _unit->error(os.str()); } else { - ParamDeclList params = parameters(); - for(ParamDeclList::const_iterator p = params.begin(); p != params.end(); ++p) + for (const auto& p : parameters()) { - if((*p)->optional() && (*p)->tag() == tag) + if(p->optional() && p->tag() == tag) { - _unit->error(msg); + _unit->error(os.str()); break; } } @@ -5412,17 +4984,13 @@ Slice::Operation::setExceptionList(const ExceptionList& el) { _throws = el; - // // Check that no exception occurs more than once in the throws clause. - // ExceptionList uniqueExceptions = el; uniqueExceptions.sort(containedCompare); uniqueExceptions.unique(containedEqual); - if(uniqueExceptions.size() != el.size()) + if (uniqueExceptions.size() != el.size()) { - // // At least one exception appears twice. - // ExceptionList tmp = el; tmp.sort(containedCompare); ExceptionList duplicates; @@ -5433,23 +5001,24 @@ Slice::Operation::setExceptionList(const ExceptionList& el) uniqueExceptions.end(), back_inserter(duplicates), containedCompare); - string msg = "operation `" + name() + "' has a throws clause with "; + ostringstream os; + os << "operation `" << name() << "' has a throws clause with "; if(duplicates.size() == 1) { - msg += "a "; + os << "a "; } - msg += "duplicate exception"; + os << "duplicate exception"; if(duplicates.size() > 1) { - msg += "s"; + os << "s"; } ExceptionList::const_iterator i = duplicates.begin(); - msg += ": `" + (*i)->name() + "'"; + os << ": `" << (*i)->name() << "'"; for(i = ++i; i != duplicates.end(); ++i) { - msg += ", `" + (*i)->name() + "'"; + os << ", `" << (*i)->name() << "'"; } - _unit->error(msg); + _unit->error(os.str()); } } @@ -5459,25 +5028,6 @@ Slice::Operation::containedType() const return ContainedTypeOperation; } -bool -Slice::Operation::uses(const ContainedPtr& contained) const -{ - if (dynamic_pointer_cast(_returnType) == contained) - { - return true; - } - - for (const auto& q : _throws) - { - if (dynamic_pointer_cast(q) == contained) - { - return true; - } - } - - return false; -} - bool Slice::Operation::sendsClasses(bool includeOptional) const { @@ -5635,12 +5185,6 @@ Slice::ParamDecl::containedType() const return ContainedTypeDataMember; } -bool -Slice::ParamDecl::uses(const ContainedPtr& contained) const -{ - return dynamic_pointer_cast(_type) == contained; -} - string Slice::ParamDecl::kindOf() const { @@ -5710,18 +5254,6 @@ Slice::DataMember::containedType() const return ContainedTypeDataMember; } -bool -Slice::DataMember::uses(const ContainedPtr& contained) const -{ - ContainedPtr contained2 = dynamic_pointer_cast(_type); - if(contained2 && contained2 == contained) - { - return true; - } - - return false; -} - string Slice::DataMember::kindOf() const { @@ -5753,9 +5285,9 @@ Slice::DataMember::DataMember(const ContainerPtr& container, const string& name, // ---------------------------------------------------------------------- UnitPtr -Slice::Unit::createUnit(bool ignRedefs, bool all, const StringList& defaultGlobalMetadata) +Slice::Unit::createUnit(bool all, const StringList& defaultGlobalMetadata) { - auto unit = make_shared(ignRedefs, all, defaultGlobalMetadata); + auto unit = make_shared(all, defaultGlobalMetadata); unit->init(); return unit; } @@ -5766,12 +5298,6 @@ Slice::Unit::init() _unit = dynamic_pointer_cast(shared_from_this()); } -bool -Slice::Unit::ignRedefs() const -{ - return _ignRedefs; -} - void Slice::Unit::setComment(const string& comment) { @@ -5864,6 +5390,7 @@ Slice::Unit::currentLine() const { return slice_lineno; } + int Slice::Unit::setCurrentFile(const std::string& currentFile, int lineNumber) { @@ -6037,7 +5564,7 @@ Slice::Unit::findDefinitionContext(const string& file) const { return p->second; } - return 0; + return nullptr; } void @@ -6047,23 +5574,6 @@ Slice::Unit::addContent(const ContainedPtr& contained) _contentMap[scoped].push_back(contained); } -void -Slice::Unit::removeContent(const ContainedPtr& contained) -{ - string scoped = IceUtilInternal::toLower(contained->scoped()); - map::iterator p = _contentMap.find(scoped); - assert(p != _contentMap.end()); - for(ContainedList::iterator q = p->second.begin(); q != p->second.end(); ++q) - { - if(q->get() == contained.get()) - { - p->second.erase(q); - return; - } - } - assert(false); -} - ContainedList Slice::Unit::findContents(const string& scoped) const { @@ -6082,69 +5592,6 @@ Slice::Unit::findContents(const string& scoped) const } } -ClassList -Slice::Unit::findDerivedClasses(const ClassDefPtr& cl) const -{ - ClassList derived; - for (map::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p) - { - for (const auto& q : p->second) - { - ClassDefPtr r = dynamic_pointer_cast(q); - if(r && r->base() == cl) - { - derived.push_back(r); - } - } - } - derived.sort(containedCompare); - derived.unique(containedEqual); - return derived; -} - -ExceptionList -Slice::Unit::findDerivedExceptions(const ExceptionPtr& ex) const -{ - ExceptionList derived; - for(const auto& [key, contents] : _contentMap) - { - for(const auto& q : contents) - { - ExceptionPtr r = dynamic_pointer_cast(q); - if(r) - { - ExceptionPtr base = r->base(); - if(base && base == ex) - { - derived.push_back(r); - } - } - } - } - derived.sort(containedCompare); - derived.unique(containedEqual); - return derived; -} - -ContainedList -Slice::Unit::findUsedBy(const ContainedPtr& contained) const -{ - ContainedList usedBy; - for (const auto& [key, contents] : _contentMap) - { - for (const auto& q : contents) - { - if (q->uses(contained)) - { - usedBy.push_back(q); - } - } - } - usedBy.sort(containedCompare); - usedBy.unique(containedEqual); - return usedBy; -} - void Slice::Unit::addTypeId(int compactId, const std::string& typeId) { @@ -6168,60 +5615,6 @@ Slice::Unit::hasCompactTypeId() const return _typeIds.size() > 0; } -bool -Slice::Unit::usesNonLocals() const -{ - for(map::const_iterator p = _contentMap.begin(); p != _contentMap.end(); ++p) - { - for (const auto& q : p->second) - { - if(dynamic_pointer_cast(q)) - { - return true; - } - - if(dynamic_pointer_cast(q)) - { - return true; - } - } - } - - if(_builtins.find(Builtin::KindObject) != _builtins.end()) - { - return true; - } - - if(_builtins.find(Builtin::KindObjectProxy) != _builtins.end()) - { - return true; - } - - if(_builtins.find(Builtin::KindValue) != _builtins.end()) - { - return true; - } - - return false; -} - -bool -Slice::Unit::usesConsts() const -{ - for(const auto& [key, contents] : _contentMap) - { - for (const auto& q : contents) - { - if (dynamic_pointer_cast(q)) - { - return true; - } - } - } - - return false; -} - StringList Slice::Unit::includeFiles() const { @@ -6232,7 +5625,7 @@ StringList Slice::Unit::allFiles() const { StringList result; - for(const auto& [key, value] : _definitionContextMap) + for (const auto& [key, value] : _definitionContextMap) { result.push_back(key); } @@ -6347,10 +5740,9 @@ Slice::Unit::getTopLevelModules(const string& file) const } } -Slice::Unit::Unit(bool ignRedefs, bool all, const StringList& defaultGlobalMetadata) : +Slice::Unit::Unit(bool all, const StringList& defaultGlobalMetadata) : SyntaxTreeBase(nullptr), Container(nullptr), - _ignRedefs(ignRedefs), _all(all), _defaultGlobalMetaData(defaultGlobalMetadata), _errors(0), @@ -6359,21 +5751,6 @@ Slice::Unit::Unit(bool ignRedefs, bool all, const StringList& defaultGlobalMetad { } -void -Slice::Unit::eraseWhiteSpace(string& s) -{ - string::size_type idx = s.find_first_not_of(" \t\r"); - if(idx != string::npos) - { - s.erase(0, idx); - } - idx = s.find_last_not_of(" \t\r"); - if(idx != string::npos) - { - s.erase(++idx); - } -} - // ---------------------------------------------------------------------- // CICompare // ---------------------------------------------------------------------- diff --git a/cpp/src/Slice/Parser.h b/cpp/src/Slice/Parser.h index bb60a082720..a9272540d94 100644 --- a/cpp/src/Slice/Parser.h +++ b/cpp/src/Slice/Parser.h @@ -165,7 +165,6 @@ using OperationList = std::list; using DataMemberList = std::list; using ParamDeclList = std::list; using EnumeratorList = std::list; -using ConstructedSet = std::set; struct ConstDef { @@ -452,7 +451,6 @@ class Contained : public virtual SyntaxTreeBase bool findMetaData(const std::string&, std::string&) const; std::list getMetaData() const; void setMetaData(const std::list&); - void addMetaData(const std::string&); // TODO: remove this method once "cs:" and "vb:" are hard errors. static FormatType parseFormatMetaData(const std::list&); @@ -474,7 +472,6 @@ class Contained : public virtual SyntaxTreeBase }; virtual ContainedType containedType() const = 0; - virtual bool uses(const ContainedPtr&) const = 0; virtual std::string kindOf() const = 0; protected: @@ -542,26 +539,21 @@ class Container : public virtual SyntaxTreeBase bool hasInterfaceDecls() const; bool hasInterfaceDefs() const; bool hasValueDefs() const; - bool hasOnlyClassDecls() const; - bool hasOnlyInterfaces() const; bool hasOperations() const; bool hasOtherConstructedOrExceptions() const; // Exceptions or constructed types other than classes. bool hasContentsWithMetaData(const std::string&) const; bool hasAsyncOps() const; bool hasContained(Contained::ContainedType) const; std::string thisScope() const; - void mergeModules(); void sort(); void sortContents(bool); virtual void visit(ParserVisitor*, bool); - void containerRecDependencies(ConstructedSet&); // Internal operation, don't use directly. bool checkIntroduced(const std::string&, ContainedPtr = 0); bool checkForGlobalDef(const std::string&, const char *); protected: - bool checkGlobalMetaData(const StringList&, const StringList&); bool validateConstant(const std::string&, const TypePtr&, SyntaxTreeBasePtr&, const std::string&, bool); EnumeratorPtr validateEnumerator(const std::string&); @@ -579,7 +571,6 @@ class Module : public virtual Container, public virtual Contained Module(const ContainerPtr&, const std::string&); virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); @@ -597,8 +588,6 @@ class Constructed : public virtual Type, public virtual Contained Constructed(const ContainerPtr&, const std::string&); virtual std::string typeId() const; virtual bool isVariableLength() const = 0; - ConstructedList dependencies(); - virtual void recDependencies(ConstructedSet&) = 0; // Internal operation, don't use directly. }; // ---------------------------------------------------------------------- @@ -613,14 +602,12 @@ class ClassDecl : public virtual Constructed virtual void destroy(); ClassDefPtr definition() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; virtual bool isVariableLength() const; virtual void visit(ParserVisitor*, bool); virtual std::string kindOf() const; - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. protected: @@ -664,7 +651,6 @@ class ClassDef : public virtual Container, public virtual Contained bool inheritsMetaData(const std::string&) const; bool hasBaseDataMembers() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual void visit(ParserVisitor*, bool); int compactId() const; StringList ids() const; @@ -692,14 +678,12 @@ class InterfaceDecl : public virtual Constructed virtual void destroy(); InterfaceDefPtr definition() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; virtual bool isVariableLength() const; virtual void visit(ParserVisitor*, bool); virtual std::string kindOf() const; - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. static void checkBasesAreLegal(const std::string&, const InterfaceList&, const UnitPtr&); @@ -757,7 +741,6 @@ class Operation : public virtual Contained, public virtual Container ExceptionList throws() const; void setExceptionList(const ExceptionList&); virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; bool sendsClasses(bool) const; bool returnsClasses(bool) const; bool returnsData() const; @@ -806,7 +789,6 @@ class InterfaceDef : public virtual Container, public virtual Contained bool hasOperations() const; bool inheritsMetaData(const std::string&) const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); StringList ids() const; @@ -842,7 +824,6 @@ class Exception : public virtual Container, public virtual Contained ExceptionList allBases() const; virtual bool isBaseOf(const ExceptionPtr&) const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; bool usesClasses(bool) const; bool hasDefaultValues() const; bool inheritsMetaData(const std::string&) const; @@ -871,7 +852,6 @@ class Struct : public virtual Container, public virtual Constructed DataMemberList dataMembers() const; DataMemberList classDataMembers() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; @@ -879,7 +859,6 @@ class Struct : public virtual Container, public virtual Constructed bool hasDefaultValues() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. friend class Container; }; @@ -896,14 +875,12 @@ class Sequence : public virtual Constructed TypePtr type() const; StringList typeMetaData() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; virtual bool isVariableLength() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. protected: @@ -928,14 +905,12 @@ class Dictionary : public virtual Constructed StringList keyMetaData() const; StringList valueMetaData() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; virtual bool isVariableLength() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. static bool legalKeyType(const TypePtr&, bool&); @@ -963,14 +938,12 @@ class Enum : public virtual Container, public virtual Constructed int minValue() const; int maxValue() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual bool usesClasses() const; virtual size_t minWireSize() const; virtual std::string getTagFormat() const; virtual bool isVariableLength() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); - virtual void recDependencies(ConstructedSet&); // Internal operation, don't use directly. protected: @@ -997,7 +970,6 @@ class Enumerator : public virtual Contained Enumerator(const ContainerPtr&, const std::string&, int); virtual void init(); EnumPtr type() const; - virtual bool uses(const ContainedPtr&) const; virtual ContainedType containedType() const; virtual std::string kindOf() const; @@ -1027,7 +999,6 @@ class Const : public virtual Contained SyntaxTreeBasePtr valueType() const; std::string value() const; std::string literal() const; - virtual bool uses(const ContainedPtr&) const; virtual ContainedType containedType() const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); @@ -1057,7 +1028,6 @@ class ParamDecl : public virtual Contained bool optional() const; int tag() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); @@ -1088,7 +1058,6 @@ class DataMember : public virtual Contained std::string defaultLiteral() const; SyntaxTreeBasePtr defaultValueType() const; virtual ContainedType containedType() const; - virtual bool uses(const ContainedPtr&) const; virtual std::string kindOf() const; virtual void visit(ParserVisitor*, bool); @@ -1114,10 +1083,9 @@ class Unit : public virtual Container { public: - Unit(bool, bool, const StringList&); - static UnitPtr createUnit(bool, bool, const StringList& = StringList()); + static UnitPtr createUnit(bool, const StringList& = StringList()); - bool ignRedefs() const; + Unit(bool, const StringList&); void setComment(const std::string&); void addToComment(const std::string&); @@ -1146,19 +1114,12 @@ class Unit : public virtual Container DefinitionContextPtr findDefinitionContext(const std::string&) const; void addContent(const ContainedPtr&); - void removeContent(const ContainedPtr&); ContainedList findContents(const std::string&) const; - ClassList findDerivedClasses(const ClassDefPtr&) const; - ExceptionList findDerivedExceptions(const ExceptionPtr&) const; - ContainedList findUsedBy(const ContainedPtr&) const; void addTypeId(int, const std::string&); std::string getTypeId(int) const; bool hasCompactTypeId() const; - bool usesNonLocals() const; - bool usesConsts() const; - // // Returns the path names of the files included directly by the top-level file. // @@ -1182,9 +1143,7 @@ class Unit : public virtual Container private: void init(); - static void eraseWhiteSpace(::std::string&); - bool _ignRedefs; bool _all; StringList _defaultGlobalMetaData; int _errors; diff --git a/cpp/src/Slice/Python.cpp b/cpp/src/Slice/Python.cpp index 4e548843a76..f34b734257a 100644 --- a/cpp/src/Slice/Python.cpp +++ b/cpp/src/Slice/Python.cpp @@ -601,7 +601,7 @@ Slice::Python::compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -648,7 +648,7 @@ Slice::Python::compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, all); + UnitPtr u = Unit::createUnit(all); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/Slice/Ruby.cpp b/cpp/src/Slice/Ruby.cpp index 4cf694a45ec..df07578e73a 100644 --- a/cpp/src/Slice/Ruby.cpp +++ b/cpp/src/Slice/Ruby.cpp @@ -196,7 +196,7 @@ Slice::Ruby::compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -243,7 +243,7 @@ Slice::Ruby::compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, all); + UnitPtr u = Unit::createUnit(all); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/ice2slice/Main.cpp b/cpp/src/ice2slice/Main.cpp index d87b2a0dc85..69452d658ed 100644 --- a/cpp/src/ice2slice/Main.cpp +++ b/cpp/src/ice2slice/Main.cpp @@ -197,7 +197,7 @@ compile(const vector& argv) } else { - UnitPtr p = Unit::createUnit(false, false); + UnitPtr p = Unit::createUnit(false); int parseStatus = p->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp index 84dcb3d3243..8b5dc4ef2aa 100644 --- a/cpp/src/slice2cpp/Main.cpp +++ b/cpp/src/slice2cpp/Main.cpp @@ -245,7 +245,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); string ext = headerExtension; @@ -303,7 +303,7 @@ compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp index 1f119bf7705..e0292ee5ff0 100644 --- a/cpp/src/slice2cs/Main.cpp +++ b/cpp/src/slice2cs/Main.cpp @@ -227,7 +227,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -273,7 +273,7 @@ compile(const vector& argv) } else { - UnitPtr p = Unit::createUnit(false, false); + UnitPtr p = Unit::createUnit(false); int parseStatus = p->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp index 10893da8016..05ee817e133 100644 --- a/cpp/src/slice2java/Main.cpp +++ b/cpp/src/slice2java/Main.cpp @@ -221,7 +221,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -272,7 +272,7 @@ compile(const vector& argv) } else { - UnitPtr p = Unit::createUnit(false, false, globalMetadata); + UnitPtr p = Unit::createUnit(false, globalMetadata); int parseStatus = p->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2js/Gen.cpp b/cpp/src/slice2js/Gen.cpp index 9e11d7b4bad..65c605c45a6 100644 --- a/cpp/src/slice2js/Gen.cpp +++ b/cpp/src/slice2js/Gen.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include // TODO: fix this warning! diff --git a/cpp/src/slice2js/JsUtil.cpp b/cpp/src/slice2js/JsUtil.cpp index b1199f82501..5623f0566c3 100644 --- a/cpp/src/slice2js/JsUtil.cpp +++ b/cpp/src/slice2js/JsUtil.cpp @@ -12,11 +12,9 @@ #include #ifdef _WIN32 -#include -#endif - -#ifndef _WIN32 -#include +# include +#else +# include #endif // TODO: fix this warning! diff --git a/cpp/src/slice2js/Main.cpp b/cpp/src/slice2js/Main.cpp index 65c38664ac9..ace5236c192 100644 --- a/cpp/src/slice2js/Main.cpp +++ b/cpp/src/slice2js/Main.cpp @@ -248,7 +248,7 @@ compile(const vector& argv) if(depend || dependJSON || dependxml) { - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -301,7 +301,7 @@ compile(const vector& argv) } else { - UnitPtr p = Unit::createUnit(false, false); + UnitPtr p = Unit::createUnit(false); int parseStatus = p->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2matlab/Main.cpp b/cpp/src/slice2matlab/Main.cpp index 9f42d25f689..4d6844358c7 100644 --- a/cpp/src/slice2matlab/Main.cpp +++ b/cpp/src/slice2matlab/Main.cpp @@ -4698,7 +4698,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -4747,7 +4747,7 @@ compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, all); + UnitPtr u = Unit::createUnit(all); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2objc/Gen.cpp b/cpp/src/slice2objc/Gen.cpp index 8a544d090a7..f83f390fc24 100644 --- a/cpp/src/slice2objc/Gen.cpp +++ b/cpp/src/slice2objc/Gen.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include using namespace std; diff --git a/cpp/src/slice2objc/Main.cpp b/cpp/src/slice2objc/Main.cpp index 6d6cb7c4c17..2b848fbdd81 100644 --- a/cpp/src/slice2objc/Main.cpp +++ b/cpp/src/slice2objc/Main.cpp @@ -206,7 +206,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -253,7 +253,7 @@ compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2objc/ObjCUtil.cpp b/cpp/src/slice2objc/ObjCUtil.cpp index 14dea4f6f13..885341345ce 100644 --- a/cpp/src/slice2objc/ObjCUtil.cpp +++ b/cpp/src/slice2objc/ObjCUtil.cpp @@ -12,11 +12,11 @@ #include #ifdef _WIN32 -#include +# include #endif #ifndef _WIN32 -#include +# include #endif using namespace std; diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp index 2e083e9ad5e..af35a964718 100644 --- a/cpp/src/slice2php/Main.cpp +++ b/cpp/src/slice2php/Main.cpp @@ -1528,7 +1528,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -1575,7 +1575,7 @@ compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, all); + UnitPtr u = Unit::createUnit(all); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/cpp/src/slice2swift/Gen.cpp b/cpp/src/slice2swift/Gen.cpp index 0624473c70c..4ee8ae7a3bf 100644 --- a/cpp/src/slice2swift/Gen.cpp +++ b/cpp/src/slice2swift/Gen.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include "Gen.h" diff --git a/cpp/src/slice2swift/Main.cpp b/cpp/src/slice2swift/Main.cpp index ffc550c32a2..df1b20f251d 100644 --- a/cpp/src/slice2swift/Main.cpp +++ b/cpp/src/slice2swift/Main.cpp @@ -209,7 +209,7 @@ compile(const vector& argv) return EXIT_FAILURE; } - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); u->destroy(); @@ -256,7 +256,7 @@ compile(const vector& argv) } else { - UnitPtr u = Unit::createUnit(false, false); + UnitPtr u = Unit::createUnit(false); int parseStatus = u->parse(*i, cppHandle, debug); if(!icecpp->close()) diff --git a/python/modules/IcePy/Slice.cpp b/python/modules/IcePy/Slice.cpp index 5f0ba4b4a47..a30829f50dc 100644 --- a/python/modules/IcePy/Slice.cpp +++ b/python/modules/IcePy/Slice.cpp @@ -122,7 +122,6 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) debug = opts.isSet("d") || opts.isSet("debug"); all = opts.isSet("all"); - bool ignoreRedefs = false; bool keepComments = true; for(vector::const_iterator p = files.begin(); p != files.end(); ++p) @@ -137,7 +136,7 @@ IcePy_loadSlice(PyObject* /*self*/, PyObject* args) return 0; } - UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all); + UnitPtr u = Slice::Unit::createUnit(all); int parseStatus = u->parse(file, cppHandle, debug); if(!icecpp->close() || parseStatus == EXIT_FAILURE) diff --git a/ruby/src/IceRuby/Slice.cpp b/ruby/src/IceRuby/Slice.cpp index 994ff4eb7b6..98f1eb7c4d8 100644 --- a/ruby/src/IceRuby/Slice.cpp +++ b/ruby/src/IceRuby/Slice.cpp @@ -105,8 +105,6 @@ IceRuby_loadSlice(int argc, VALUE* argv, VALUE /*self*/) debug = opts.isSet("d") || opts.isSet("debug"); all = opts.isSet("all"); - bool ignoreRedefs = false; - for(vector::const_iterator p = files.begin(); p != files.end(); ++p) { string file = *p; @@ -118,7 +116,7 @@ IceRuby_loadSlice(int argc, VALUE* argv, VALUE /*self*/) throw RubyException(rb_eArgError, "Slice preprocessing failed for `%s'", cmd.c_str()); } - UnitPtr u = Slice::Unit::createUnit(ignoreRedefs, all); + UnitPtr u = Slice::Unit::createUnit(all); int parseStatus = u->parse(file, cppHandle, debug); if(!icecpp->close() || parseStatus == EXIT_FAILURE)