Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
f68b251f
Commit
f68b251f
authored
Jul 24, 2019
by
Josh Humphries
Committed by
Adam Cozzette
Jul 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't emit location for label unless label is present
parent
2849a799
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
8 deletions
+11
-8
parser.cc
src/google/protobuf/compiler/parser.cc
+10
-8
parser.h
src/google/protobuf/compiler/parser.h
+1
-0
No files found.
src/google/protobuf/compiler/parser.cc
View file @
f68b251f
...
...
@@ -902,10 +902,8 @@ bool Parser::ParseMessageField(FieldDescriptorProto* field,
const
LocationRecorder
&
field_location
,
const
FileDescriptorProto
*
containing_file
)
{
{
LocationRecorder
location
(
field_location
,
FieldDescriptorProto
::
kLabelFieldNumber
);
FieldDescriptorProto
::
Label
label
;
if
(
ParseLabel
(
&
label
,
containing_file
))
{
if
(
ParseLabel
(
&
label
,
field_location
,
containing_file
))
{
field
->
set_label
(
label
);
if
(
label
==
FieldDescriptorProto
::
LABEL_OPTIONAL
&&
syntax_identifier_
==
"proto3"
)
{
...
...
@@ -2206,18 +2204,22 @@ bool Parser::ParseMethodOptions(const LocationRecorder& parent_location,
// -------------------------------------------------------------------
bool
Parser
::
ParseLabel
(
FieldDescriptorProto
::
Label
*
label
,
const
LocationRecorder
&
field_location
,
const
FileDescriptorProto
*
containing_file
)
{
if
(
!
LookingAt
(
"optional"
)
&&
!
LookingAt
(
"repeated"
)
&&
!
LookingAt
(
"required"
))
{
return
false
;
}
LocationRecorder
location
(
field_location
,
FieldDescriptorProto
::
kLabelFieldNumber
);
if
(
TryConsume
(
"optional"
))
{
*
label
=
FieldDescriptorProto
::
LABEL_OPTIONAL
;
return
true
;
}
else
if
(
TryConsume
(
"repeated"
))
{
*
label
=
FieldDescriptorProto
::
LABEL_REPEATED
;
return
true
;
}
else
if
(
TryConsume
(
"required"
))
{
}
else
{
Consume
(
"required"
);
*
label
=
FieldDescriptorProto
::
LABEL_REQUIRED
;
return
true
;
}
return
fals
e
;
return
tru
e
;
}
bool
Parser
::
ParseType
(
FieldDescriptorProto
::
Type
*
type
,
...
...
src/google/protobuf/compiler/parser.h
View file @
f68b251f
...
...
@@ -440,6 +440,7 @@ class PROTOBUF_EXPORT Parser {
// Parse "required", "optional", or "repeated" and fill in "label"
// with the value. Returns true if such a label is consumed.
bool
ParseLabel
(
FieldDescriptorProto
::
Label
*
label
,
const
LocationRecorder
&
field_location
,
const
FileDescriptorProto
*
containing_file
);
// Parse a type name and fill in "type" (if it is a primitive) or
...
...
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