Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bcc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
bcc
Commits
8b8e16b7
Commit
8b8e16b7
authored
Oct 10, 2017
by
yonghong-song
Committed by
GitHub
Oct 10, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1385 from pchaigno/support-enums-map-visitor
Fix segfault with enumerations
parents
54a5b4d1
f7f873a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
src/cc/json_map_decl_visitor.cc
src/cc/json_map_decl_visitor.cc
+21
-0
tests/python/test_clang.py
tests/python/test_clang.py
+12
-0
No files found.
src/cc/json_map_decl_visitor.cc
View file @
8b8e16b7
...
...
@@ -40,6 +40,8 @@ class BMapDeclVisitor : public clang::RecursiveASTVisitor<BMapDeclVisitor> {
bool
VisitTypedefType
(
const
clang
::
TypedefType
*
T
);
bool
VisitTagType
(
const
clang
::
TagType
*
T
);
bool
VisitPointerType
(
const
clang
::
PointerType
*
T
);
bool
VisitEnumConstantDecl
(
clang
::
EnumConstantDecl
*
D
);
bool
VisitEnumDecl
(
clang
::
EnumDecl
*
D
);
private:
clang
::
ASTContext
&
C
;
...
...
@@ -55,6 +57,25 @@ bool BMapDeclVisitor::VisitFieldDecl(FieldDecl *D) {
return
true
;
}
bool
BMapDeclVisitor
::
VisitEnumConstantDecl
(
EnumConstantDecl
*
D
)
{
result_
+=
"
\"
"
;
result_
+=
D
->
getName
();
result_
+=
"
\"
,"
;
return
false
;
}
bool
BMapDeclVisitor
::
VisitEnumDecl
(
EnumDecl
*
D
)
{
result_
+=
"[
\"
"
;
result_
+=
D
->
getName
();
result_
+=
"
\"
, ["
;
for
(
auto
it
=
D
->
enumerator_begin
();
it
!=
D
->
enumerator_end
();
++
it
)
{
TraverseDecl
(
*
it
);
}
result_
.
erase
(
result_
.
end
()
-
1
);
result_
+=
"],
\"
enum
\"
]"
;
return
false
;
}
bool
BMapDeclVisitor
::
TraverseRecordDecl
(
RecordDecl
*
D
)
{
// skip children, handled in Visit...
if
(
!
WalkUpFromRecordDecl
(
D
))
...
...
tests/python/test_clang.py
View file @
8b8e16b7
...
...
@@ -612,6 +612,18 @@ struct key_t {
with
self
.
assertRaises
(
Exception
):
b
=
BPF
(
text
=
text
)
def
test_enumerations
(
self
):
text
=
"""
enum b {
CHOICE_A,
};
struct a {
enum b test;
};
BPF_HASH(drops, struct a);
"""
b
=
BPF
(
text
=
text
)
if
__name__
==
"__main__"
:
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment