This file is indexed.

/usr/lib/python2.7/dist-packages/pygccxml/declarations/declaration_utils.py is in python-pygccxml 1.8.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# Copyright 2014-2016 Insight Software Consortium.
# Copyright 2004-2008 Roman Yakovenko.
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt


def declaration_path(decl, with_defaults=True):
    """
    Returns a list of parent declarations names.

    :param decl: declaration for which declaration path should be calculated
    :type decl: :class:`declaration_t`

    :rtype: [names], where first item contains top parent name and last item
             contains the `decl` name

    """

    if not decl:
        return []
    if not decl.cache.declaration_path:
        result = [decl.name]
        parent = decl.parent
        while parent:
            if parent.cache.declaration_path:
                result.reverse()
                decl.cache.declaration_path = parent.cache.declaration_path + \
                    result
                return decl.cache.declaration_path
            else:
                result.append(parent.name)
                parent = parent.parent
        result.reverse()
        decl.cache.declaration_path = result
        return result
    else:
        return decl.cache.declaration_path


def partial_declaration_path(decl):
    """
    Returns a list of parent declarations names without template arguments that
    have default value.

    :param decl: declaration for which declaration path should be calculated
    :type decl: :class:`declaration_t`

    :rtype: [names], where first item contains top parent name and last item
             contains the `decl` name

    """

    # TODO:
    # If parent declaration cache already has declaration_path, reuse it for
    # calculation.
    if not decl:
        return []
    if not decl.cache.partial_declaration_path:
        result = [decl.partial_name]
        parent = decl.parent
        while parent:
            if parent.cache.partial_declaration_path:
                result.reverse()
                decl.cache.partial_declaration_path \
                    = parent.cache.partial_declaration_path + result
                return decl.cache.partial_declaration_path
            else:
                result.append(parent.partial_name)
                parent = parent.parent
        result.reverse()
        decl.cache.partial_declaration_path = result
        return result
    else:
        return decl.cache.partial_declaration_path


def full_name_from_declaration_path(dpath):
    # Here I have lack of knowledge:
    # TODO: "What is the full name of declaration declared in unnamed
    # namespace?"
    result = [_f for _f in dpath if _f]
    result = result[0] + '::'.join(result[1:])
    return result


def full_name(decl, with_defaults=True):
    """
    Returns declaration full qualified name.

    If `decl` belongs to anonymous namespace or class, the function will return
    C++ illegal qualified name.
    :param decl: :class:`declaration_t`
    :type decl: :class:`declaration_t`
    :rtype: full name of declarations.

    """

    if None is decl:
        raise RuntimeError("Unable to generate full name for None object!")
    if with_defaults:
        if not decl.cache.full_name:
            path = declaration_path(decl)
            if path == [""]:
                # Declarations without names are allowed (for examples class
                # or struct instances). In this case set an empty name..
                decl.cache.full_name = ""
            else:
                decl.cache.full_name = full_name_from_declaration_path(path)
        return decl.cache.full_name
    else:
        if not decl.cache.full_partial_name:
            path = partial_declaration_path(decl)
            if path == [""]:
                # Declarations without names are allowed (for examples class
                # or struct instances). In this case set an empty name.
                decl.cache.full_partial_name = ""
            else:
                decl.cache.full_partial_name = \
                    full_name_from_declaration_path(path)
        return decl.cache.full_partial_name


def get_named_parent(decl):
    """
    Returns a reference to a named parent declaration.

    :param decl: the child declaration
    :type decl: :class:`declaration_t`

    :rtype: reference to :class:`declaration_t` or None if not found

    """

    if not decl:
        return None

    parent = decl.parent
    while parent and (not parent.name or parent.name == '::'):
        parent = parent.parent
    return parent