title: OCLint ASTMatcher rule. Matching NS_ENUM
body: <p>I am trying to create an OCLint rule that matches both <code>typedef enum</code> and <code>typedef NS_ENUM</code> declarations, with little success.
  I have an Objective-C file (TestClass.m) with the following enum declarations in it:</p>
  
  <pre><code>typedef NS_ENUM(NSInteger, TestEnum) {
      TestEnumNone,
      TestEnumSome,
      TestEnumAll
  };
  
  typedef enum {
      othertestvalue = 0,
      othertestvalue1,
      othertestvalue2
  } OtherTestEnum;
  </code></pre>
  
  <p>Dumping the AST with this command:</p>
  
  <pre><code>clang -Xclang -ast-dump -fsyntax-only Classes/TestClass.m -- | grep Enum
  </code></pre>
  
  <p>Gives me this output containing this:</p>
  
  <pre><code>|-TypedefDecl 0x7f9d3accd630 &lt;col:1, col:28&gt; col:28 TestEnum 'enum TestEnum':'enum TestEnum'
  |-EnumDecl 0x7f9d3accd6a8 prev 0x7f9d3accd530 &lt;/System/Library/Frameworks/CoreFoundation.framework/Headers/CFAvailability.h:171:57, Classes/TestClass.m:71:1&gt; line:67:28 TestEnum 'NSInteger':'long'
  | |-EnumConstantDecl 0x7f9d3accd738 &lt;line:68:5&gt; col:5 TestEnumNone 'NSInteger':'long'
  | |-EnumConstantDecl 0x7f9d3accd788 &lt;line:69:5&gt; col:5 TestEnumSome 'NSInteger':'long'
  | `-EnumConstantDecl 0x7f9d3accd7d8 &lt;line:70:5&gt; col:5 TestEnumAll 'NSInteger':'long'
  |-EnumDecl 0x7f9d3accd828 &lt;line:73:9, line:77:1&gt; line:73:9
  | |-EnumConstantDecl 0x7f9d3accd900 &lt;line:74:5, col:22&gt; col:5 othertestvalue 'int'
  | |-EnumConstantDecl 0x7f9d3accd950 &lt;line:75:5&gt; col:5 othertestvalue1 'int'
  | `-EnumConstantDecl 0x7f9d3accd9a0 &lt;line:76:5&gt; col:5 othertestvalue2 'int'
  |-TypedefDecl 0x7f9d3accda40 &lt;line:73:1, line:77:3&gt; col:3 OtherTestEnum 'enum OtherTestEnum':'OtherTestEnum'
  </code></pre>
  
  <p>I have an ASTMatcherRule (ObjCNsEnumRule) where I am trying to match both <code>typedef enum</code> as well as <code>typedef NS_ENUM</code> Here is the code for that:</p>
  
  <pre><code>#include "oclint/AbstractASTMatcherRule.h"
  #include "oclint/RuleSet.h"
  
  using namespace std;
  using namespace clang;
  using namespace clang::ast_matchers;
  using namespace oclint;
  
  class ObjCNsEnumRuleRule : public AbstractASTMatcherRule
  {
  public:
  virtual const string name() const override
  {
      return "obj c ns enum rule";
  }
  
  virtual int priority() const override
  {
      return 3;
  }
  
  virtual void callback(const MatchFinder::MatchResult &amp;result) override
  {
    const EnumDecl *enumDecl = result.Nodes.getNodeAs&lt;EnumDecl&gt;("enum");
    if (enumDecl) {
      addViolation(enumDecl, this, "Found enum");
    }
  }
  
  virtual void setUpMatcher() override
  {
    addMatcher(enumDecl().bind("enum"));
  }
  
  };
  
  static RuleSet rules(new ObjCNsEnumRuleRule());
  </code></pre>
  
  <p>However, when I run this rule, I only get the output for the <code>typedef enum</code> declaration.</p>
  
  <pre><code>Classes/TestClass.m:73:9: obj c ns enum rule P3 Found enum
  </code></pre>
  
  <p>What am I doing wrong here? Both enums show up in the AST dump, but only one matches in the OCLint rule.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I think this may have to do with the AST dump showing the <code>EnumDecl</code> for the <code>NS_ENUM</code> as defined in a different source file (probably because of the NS_ENUM macro), as I can match the typedef, but not the enumdecl.</p>