Skip to content

Commit 354577e

Browse files
committed
docs: move location-handling to its own page
1 parent ba7f34a commit 354577e

File tree

3 files changed

+64
-48
lines changed

3 files changed

+64
-48
lines changed

docs/basics.rst

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
.. Copyright 2011, 2012 David Malcolm <dmalcolm@redhat.com>
2-
Copyright 2011, 2012 Red Hat, Inc.
1+
.. Copyright 2011-2012, 2017 David Malcolm <dmalcolm@redhat.com>
2+
Copyright 2011-2012, 2017 Red Hat, Inc.
33
44
This is free software: you can redistribute it and/or modify it
55
under the terms of the GNU General Public License as published by
@@ -510,49 +510,3 @@ Global data access
510510
:py:class:`gcc.QualUnionType`, along with a string `name`, look for a
511511
field with that name within the given struct or union, returning it as a
512512
:py:class:`gcc.FieldDecl`, or None if it wasn't found
513-
514-
515-
Working with source code
516-
========================
517-
518-
.. py:function:: gccutils.get_src_for_loc(loc)
519-
520-
Given a :py:class:`gcc.Location`, get the source line as a string
521-
(without trailing whitespace or newlines)
522-
523-
.. py:class:: gcc.Location
524-
525-
Wrapper around GCC's `location_t`, representing a location within the source
526-
code. Use :py:func:`gccutils.get_src_for_loc` to get at the line of actual
527-
source code.
528-
529-
The output from __repr__ looks like this::
530-
531-
gcc.Location(file='./src/test.c', line=42)
532-
533-
The output from__str__ looks like this::
534-
535-
./src/test.c:42
536-
537-
.. py:attribute:: file
538-
539-
(string) Name of the source file (or header file)
540-
541-
.. py:attribute:: line
542-
543-
(int) Line number within source file (starting at 1, not 0)
544-
545-
.. py:attribute:: column
546-
547-
(int) Column number within source file (starting at 1, not 0)
548-
549-
.. py:attribute:: in_system_header
550-
551-
(bool) This attribute flags locations that are within a system header
552-
file. It may be of use when writing custom warnings, so that you
553-
can filter out issues in system headers, leaving just those within
554-
the user's code::
555-
556-
# Don't report on issues found in system headers:
557-
if decl.location.in_system_header:
558-
return

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Contents:
3232
gcc-overview.rst
3333
examples.rst
3434
working-with-c.rst
35+
locations.rst
3536
cfg.rst
3637
tree.rst
3738
gimple.rst

docs/locations.rst

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.. Copyright 2011-2012, 2017 David Malcolm <dmalcolm@redhat.com>
2+
Copyright 2011-2012, 2017 Red Hat, Inc.
3+
4+
This is free software: you can redistribute it and/or modify it
5+
under the terms of the GNU General Public License as published by
6+
the Free Software Foundation, either version 3 of the License, or
7+
(at your option) any later version.
8+
9+
This program is distributed in the hope that it will be useful, but
10+
WITHOUT ANY WARRANTY; without even the implied warranty of
11+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12+
General Public License for more details.
13+
14+
You should have received a copy of the GNU General Public License
15+
along with this program. If not, see
16+
<http://www.gnu.org/licenses/>.
17+
18+
Locations
19+
=========
20+
21+
.. py:function:: gccutils.get_src_for_loc(loc)
22+
23+
Given a :py:class:`gcc.Location`, get the source line as a string
24+
(without trailing whitespace or newlines)
25+
26+
.. py:class:: gcc.Location
27+
28+
Wrapper around GCC's `location_t`, representing a location within the source
29+
code. Use :py:func:`gccutils.get_src_for_loc` to get at the line of actual
30+
source code.
31+
32+
The output from __repr__ looks like this::
33+
34+
gcc.Location(file='./src/test.c', line=42)
35+
36+
The output from__str__ looks like this::
37+
38+
./src/test.c:42
39+
40+
.. py:attribute:: file
41+
42+
(string) Name of the source file (or header file)
43+
44+
.. py:attribute:: line
45+
46+
(int) Line number within source file (starting at 1, not 0)
47+
48+
.. py:attribute:: column
49+
50+
(int) Column number within source file (starting at 1, not 0)
51+
52+
.. py:attribute:: in_system_header
53+
54+
(bool) This attribute flags locations that are within a system header
55+
file. It may be of use when writing custom warnings, so that you
56+
can filter out issues in system headers, leaving just those within
57+
the user's code::
58+
59+
# Don't report on issues found in system headers:
60+
if decl.location.in_system_header:
61+
return

0 commit comments

Comments
 (0)