diff --git a/lang/tlb/export.cc b/lang/tlb/export.cc index f66076a7..78ec9fdd 100644 --- a/lang/tlb/export.cc +++ b/lang/tlb/export.cc @@ -202,7 +202,7 @@ namespace Enum::ValueMap const& values = type.values(); m_stream << "\n"; { Indent indenter(m_indent); - Enum::ValueMap::const_iterator it, end = values.end(); + Enum::ValueMap::const_iterator it; for (it = values.begin(); it != values.end(); ++it) m_stream << m_indent << "first << "\" value=\"" << it->second << "\"/>\n"; } diff --git a/tools/tlbBuilder/CMakeLists.txt b/tools/tlbBuilder/CMakeLists.txt index c3f9d185..8d9853db 100644 --- a/tools/tlbBuilder/CMakeLists.txt +++ b/tools/tlbBuilder/CMakeLists.txt @@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 2.8) # AST-headers... this only clutters up the compiler output with nonsense add_definitions("-Wno-unused-local-typedefs") +# when compiling inside the rock-framework "Wall" is used. This adds alotta +# more bogus warnings from system-headers... +add_definitions("-Wno-strict-aliasing") + include_directories("/usr/lib/llvm-3.4/include/") macro(llvm_find_config LLVM_REQUIRED_VERSION) diff --git a/tools/tlbBuilder/Extractor.cpp b/tools/tlbBuilder/Extractor.cpp index 6c732cb8..3e4f125c 100644 --- a/tools/tlbBuilder/Extractor.cpp +++ b/tools/tlbBuilder/Extractor.cpp @@ -3,10 +3,7 @@ // tool-template -- // // Example: -// ./bin/extractor $ROCK_ROOT/base/types/base/Pose.hpp -- \ -// -I$ROCK_ROOT/base/types \ -// -I/usr/include/eigen3 \ -// -x c++ +// ./bin/extractor $ROCK_ROOT/base/types/base/Pose.hpp -- -I$ROCK_ROOT/base/types -I/usr/include/eigen3 -x c++ // // keep in mind that this particular (not very complicated) example still takes 15seconds to // complete... @@ -48,35 +45,33 @@ namespace { class TypeDefCallback : public MatchFinder::MatchCallback { public: - -// This routine will get called for each thing that the matchers find. -virtual void run(const MatchFinder::MatchResult &Result) { + virtual void run(const MatchFinder::MatchResult &Result) { - const TypedefType *typeType = Result.Nodes.getNodeAs("typeDef"); - if(typeType) - { - builder.registerTypeDef(typeType); + const TypedefType *T = Result.Nodes.getNodeAs("typeDef"); + + if(T) { + builder.registerTypeDef(T); + } } -} }; -class ToolTemplateCallback : public MatchFinder::MatchCallback { - public: - // This routine will get called for each thing that the matchers find. - virtual void run(const MatchFinder::MatchResult &Result) { +class TypeDeclCallback : public MatchFinder::MatchCallback { + public: + + virtual void run(const MatchFinder::MatchResult &Result) { - const TypeDecl *decl = Result.Nodes.getNodeAs("match"); + const TypeDecl *D = Result.Nodes.getNodeAs("typeDecl"); - if(decl) - { - builder.registerNamedDecl(decl); + if(D) { + + builder.registerNamedDecl(D); + } + + const CXXRecordDecl *DD = Result.Nodes.getNodeAs("typeDecl"); + if (DD) { + builder.registerNamedDecl(DD); + } } - - const CXXRecordDecl *D = Result.Nodes.getNodeAs("match"); - if (D) { - builder.registerNamedDecl(D); - } - } }; } // end anonymous namespace @@ -91,28 +86,18 @@ int main(int argc, const char **argv) { // }}} ast_matchers::MatchFinder Finder; - ToolTemplateCallback Callback; - TypeDefCallback tdCallback; - - // AST matching ftw... - // - // the big table: http://clang.llvm.org/docs/LibASTMatchersReference.html - - // the "bind" will make the match referencable by the given string in the "run()" mathod of the - // callback - // the "isDefinition()" is needed to reject "Class Name Injection" and forward - // declarations. see https://stackoverflow.com/questions/24761684 and - // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N0444.pdf + TypeDeclCallback typeDeclCallback; internal::VariadicDynCastAllOfMatcher typeDecl; - - DeclarationMatcher matcher = typeDecl().bind("match"); - - Finder.addMatcher(matcher, &Callback); + Finder.addMatcher(typeDecl().bind("typeDecl"), &typeDeclCallback); - Finder.addMatcher(typedefType().bind("typeDef"), &tdCallback); + TypeDefCallback typeDefCallback; + Finder.addMatcher(typedefType().bind("typeDef"), &typeDefCallback); - Tool.run(newFrontendActionFactory(&Finder)); + if (int retval = Tool.run(newFrontendActionFactory(&Finder)) != 0) { + std::cerr << "whoops\n"; + return retval; + } builder.buildRegistry(); diff --git a/typelib/typemodel.cc b/typelib/typemodel.cc index 0feb34a4..7621159d 100644 --- a/typelib/typemodel.cc +++ b/typelib/typemodel.cc @@ -322,8 +322,7 @@ namespace Typelib FieldList::const_iterator left_it = m_fields.begin(), left_end = m_fields.end(), - right_it = right_type.getFields().begin(), - right_end = right_type.getFields().end(); + right_it = right_type.getFields().begin(); while (left_it != left_end) { @@ -404,7 +403,6 @@ namespace Typelib Compound const* other_compound = dynamic_cast(&other); if (other_compound) { - FieldList::const_iterator other_end = other_compound->m_fields.end(); for (FieldList::const_iterator it = m_fields.begin(); it != m_fields.end(); ++it) { Field const* other_field = other_compound->getField(it->getName()); diff --git a/typelib/typename.cc b/typelib/typename.cc index 75c68e89..af3364bf 100644 --- a/typelib/typename.cc +++ b/typelib/typename.cc @@ -9,7 +9,6 @@ using namespace Typelib; namespace { typedef std::string::value_type NamespaceMarkType; - static const NamespaceMarkType NamespaceMark = '/'; static const char* NamespaceMarkString = "/"; struct NameSeparator : public char_separator diff --git a/typelib/utilmm/configset.cc b/typelib/utilmm/configset.cc index d081ab31..be8f3c61 100644 --- a/typelib/utilmm/configset.cc +++ b/typelib/utilmm/configset.cc @@ -65,7 +65,7 @@ void config_set::insert(std::string const& name, std::string const& value) { m_values.insert( make_pair(name, value) ); } void config_set::insert(std::string const& name, std::list const& value) { - list::const_iterator it, end = value.end(); + list::const_iterator it; for (it = value.begin(); it != value.end(); ++it) insert(name, *it); }