title: clang: do friend functions not have spelling attribute?
body: <p>I want to use the clang <code>Cursor</code> class to get the <code>spelling</code> attribute of the operator function for <code>Timer</code> from python, but it won't work for a friend function.</p>
  <p>Given the C++ class <code>Timer</code> in <code>Timer.hpp</code>:</p>
  <pre class="lang-cpp prettyprint-override"><code>class Timer {
  public:
      // friend operator overload to add minutes to the timer
      friend Timer operator+=(Timer t, int add_mins) {
          // add
          return t;
      }
  };
  
  // different operator overload as a non-member non-friend function
  bool operator==(Timer t0, Timer t1) {
      return false;
  }
  </code></pre>
  <p>Here is the python code to get the <code>spelling</code> attribute:</p>
  <pre class="lang-py prettyprint-override"><code>from clang import cindex
  def print_node(node):
      if len(node.spelling) &gt; 0:
          print(&quot;Spelling for node of kind %s: %s&quot; % (node.kind, node.spelling))
      else:
          print(&quot;Node of kind %s has no spelling&quot; % node.kind)
  
  index = cindex.Index(cindex.conf.lib.clang_createIndex(False, True))
  tu = index.parse('Timer.hpp')
  file_node = tu.cursor
  for node in file_node.get_children():
      print_node(node)
      if node.kind is cindex.CursorKind.CLASS_DECL:
          for child in node.get_children():
              print_node(child)
  
          print(&quot;Node of kind %s has no spelling&quot; % child.kind)
  </code></pre>
  <p>The output of the python code is:</p>
  <pre class="lang-sh prettyprint-override"><code>Spelling for node of kind CursorKind.CLASS_DECL: Timer
  Node of kind CursorKind.CXX_ACCESS_SPEC_DECL has no spelling
  Node of kind CursorKind.FRIEND_DECL has no spelling
  Spelling for node of kind CursorKind.FUNCTION_DECL: operator==
  </code></pre>
  <p>Notice that the <code>==</code> operator has <code>spelling</code>, but the friend <code>+=</code> operator doesn't. Why is this, and is it possible to get the spelling for the friend function?</p>