Skip to content

Commit e39f631

Browse files
committed
Merge pull request #1 from jmachowinski/low_hanging_fruits
Low hanging fruits
2 parents 4d2f9ac + 20d7383 commit e39f631

File tree

6 files changed

+36
-50
lines changed

6 files changed

+36
-50
lines changed

lang/tlb/export.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ namespace
202202
Enum::ValueMap const& values = type.values();
203203
m_stream << "<enum name=\"" << type.getName() << "\" " << emitSourceID() << ">\n";
204204
{ Indent indenter(m_indent);
205-
Enum::ValueMap::const_iterator it, end = values.end();
205+
Enum::ValueMap::const_iterator it;
206206
for (it = values.begin(); it != values.end(); ++it)
207207
m_stream << m_indent << "<value symbol=\"" << it->first << "\" value=\"" << it->second << "\"/>\n";
208208
}

tools/tlbBuilder/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 2.8)
44
# AST-headers... this only clutters up the compiler output with nonsense
55
add_definitions("-Wno-unused-local-typedefs")
66

7+
# when compiling inside the rock-framework "Wall" is used. This adds alotta
8+
# more bogus warnings from system-headers...
9+
add_definitions("-Wno-strict-aliasing")
10+
711
include_directories("/usr/lib/llvm-3.4/include/")
812

913
macro(llvm_find_config LLVM_REQUIRED_VERSION)

tools/tlbBuilder/Extractor.cpp

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
// tool-template <header-to-look-at> -- <compile-flags-as-usual>
44
//
55
// Example:
6-
// ./bin/extractor $ROCK_ROOT/base/types/base/Pose.hpp -- \
7-
// -I$ROCK_ROOT/base/types \
8-
// -I/usr/include/eigen3 \
9-
// -x c++
6+
// ./bin/extractor $ROCK_ROOT/base/types/base/Pose.hpp -- -I$ROCK_ROOT/base/types -I/usr/include/eigen3 -x c++
107
//
118
// keep in mind that this particular (not very complicated) example still takes 15seconds to
129
// complete...
@@ -48,35 +45,33 @@ namespace {
4845
class TypeDefCallback : public MatchFinder::MatchCallback {
4946
public:
5047

51-
52-
// This routine will get called for each thing that the matchers find.
53-
virtual void run(const MatchFinder::MatchResult &Result) {
48+
virtual void run(const MatchFinder::MatchResult &Result) {
5449

55-
const TypedefType *typeType = Result.Nodes.getNodeAs<TypedefType>("typeDef");
56-
if(typeType)
57-
{
58-
builder.registerTypeDef(typeType);
50+
const TypedefType *T = Result.Nodes.getNodeAs<TypedefType>("typeDef");
51+
52+
if(T) {
53+
builder.registerTypeDef(T);
54+
}
5955
}
60-
}
6156
};
6257

63-
class ToolTemplateCallback : public MatchFinder::MatchCallback {
64-
public:
65-
// This routine will get called for each thing that the matchers find.
66-
virtual void run(const MatchFinder::MatchResult &Result) {
58+
class TypeDeclCallback : public MatchFinder::MatchCallback {
59+
public:
60+
61+
virtual void run(const MatchFinder::MatchResult &Result) {
6762

68-
const TypeDecl *decl = Result.Nodes.getNodeAs<TypeDecl>("match");
63+
const TypeDecl *D = Result.Nodes.getNodeAs<TypeDecl>("typeDecl");
6964

70-
if(decl)
71-
{
72-
builder.registerNamedDecl(decl);
65+
if(D) {
66+
67+
builder.registerNamedDecl(D);
68+
}
69+
70+
const CXXRecordDecl *DD = Result.Nodes.getNodeAs<CXXRecordDecl>("typeDecl");
71+
if (DD) {
72+
builder.registerNamedDecl(DD);
73+
}
7374
}
74-
75-
const CXXRecordDecl *D = Result.Nodes.getNodeAs<CXXRecordDecl>("match");
76-
if (D) {
77-
builder.registerNamedDecl(D);
78-
}
79-
}
8075

8176
};
8277
} // end anonymous namespace
@@ -91,28 +86,18 @@ int main(int argc, const char **argv) {
9186
// }}}
9287

9388
ast_matchers::MatchFinder Finder;
94-
ToolTemplateCallback Callback;
95-
TypeDefCallback tdCallback;
96-
97-
// AST matching ftw...
98-
//
99-
// the big table: http://clang.llvm.org/docs/LibASTMatchersReference.html
100-
101-
// the "bind" will make the match referencable by the given string in the "run()" mathod of the
102-
// callback
10389

104-
// the "isDefinition()" is needed to reject "Class Name Injection" and forward
105-
// declarations. see https://stackoverflow.com/questions/24761684 and
106-
// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/1994/N0444.pdf
90+
TypeDeclCallback typeDeclCallback;
10791
internal::VariadicDynCastAllOfMatcher<Decl, TypeDecl> typeDecl;
108-
109-
DeclarationMatcher matcher = typeDecl().bind("match");
110-
111-
Finder.addMatcher(matcher, &Callback);
92+
Finder.addMatcher(typeDecl().bind("typeDecl"), &typeDeclCallback);
11293

113-
Finder.addMatcher(typedefType().bind("typeDef"), &tdCallback);
94+
TypeDefCallback typeDefCallback;
95+
Finder.addMatcher(typedefType().bind("typeDef"), &typeDefCallback);
11496

115-
Tool.run(newFrontendActionFactory(&Finder));
97+
if (int retval = Tool.run(newFrontendActionFactory(&Finder)) != 0) {
98+
std::cerr << "whoops\n";
99+
return retval;
100+
}
116101

117102
builder.buildRegistry();
118103

typelib/typemodel.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,7 @@ namespace Typelib
322322

323323
FieldList::const_iterator left_it = m_fields.begin(),
324324
left_end = m_fields.end(),
325-
right_it = right_type.getFields().begin(),
326-
right_end = right_type.getFields().end();
325+
right_it = right_type.getFields().begin();
327326

328327
while (left_it != left_end)
329328
{
@@ -404,7 +403,6 @@ namespace Typelib
404403
Compound const* other_compound = dynamic_cast<Compound const*>(&other);
405404
if (other_compound)
406405
{
407-
FieldList::const_iterator other_end = other_compound->m_fields.end();
408406
for (FieldList::const_iterator it = m_fields.begin(); it != m_fields.end(); ++it)
409407
{
410408
Field const* other_field = other_compound->getField(it->getName());

typelib/typename.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ using namespace Typelib;
99
namespace
1010
{
1111
typedef std::string::value_type NamespaceMarkType;
12-
static const NamespaceMarkType NamespaceMark = '/';
1312
static const char* NamespaceMarkString = "/";
1413

1514
struct NameSeparator : public char_separator<NamespaceMarkType>

typelib/utilmm/configset.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void config_set::insert(std::string const& name, std::string const& value)
6565
{ m_values.insert( make_pair(name, value) ); }
6666
void config_set::insert(std::string const& name, std::list<std::string> const& value)
6767
{
68-
list<string>::const_iterator it, end = value.end();
68+
list<string>::const_iterator it;
6969
for (it = value.begin(); it != value.end(); ++it)
7070
insert(name, *it);
7171
}

0 commit comments

Comments
 (0)