How to know if a typedef has its own RecordDecl or not?

I have two situations like:

typedef struct {
int foo;
} bar;

and

struct _bar {
int foo;
};

typedef struct _bar bar;

  1. How can I differ from these two situations?

I have two situations like:

typedef struct {
int foo;
} bar;

and

struct _bar {
int foo;
};

typedef struct _bar bar;

  1. How can I differ from these two situations

If the first case, the RecordDecl itself with have a “typedef for anonymous tag”; there is a special accessor for it.