<div dir="ltr">Try getDeclName(), getNameAsString(), or others.  getName() only works if the name is a simple identifier:<div><br></div><div><div>  /// getName - Get the name of identifier for this declaration as a StringRef.</div>
<div>  /// This requires that the declaration have a name and that it be a simple</div><div>  /// identifier.</div><div>  StringRef getName() const {</div><div>    assert(Name.isIdentifier() && "Name is not a simple identifier");</div>
<div>    return getIdentifier() ? getIdentifier()->getName() : "";</div><div>  }</div><div><br></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 30, 2014 at 3:21 PM, Daniel Dilts <span dir="ltr"><<a href="mailto:diltsman@gmail.com" target="_blank">diltsman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>I am attempting to get the name of a CXXRecordDecl that I have identified with an AST matcher.  I am using Class->getName().str() to get the class name.</div>
<div><br></div><div>namespace N {<br>class SomeNonInterface {<br>
  virtual void func1() = 0;<br>  virtual void func2() {}<br>};</div><div>}</div><div><br></div><div>It works great for the above code.  Gives me "SomeNonInterface" as the name.</div><div><br></div><div>class N::BaseClass1 {<br>

public:<br>  BaseClass1(int i);<br>  BaseClass1(const BaseClass1 &right);<br>  virtual ~BaseClass1();<br>  BaseClass1 &operator=(const BaseClass1 &right);<br>};</div><div><br></div><div>For the above code it gives me "" as the name.</div>

<div><br></div><div>How would I get the class name so that it works in all cases, even if the name in the declaration/definition is namespace qualified?  Or...did I hit a case that isn't legal?</div></div>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>