C/C++: Handling .h file in relaxed syntax
I found this case in linux kernel.
Consider a C language header having .h suffix.
In C language private is not a keyword.
New Cxx parser doesn't record a variable named private because
the parser recognized it as C++ keyword.``
Old Cxx parser
[yamato@x201]/tmp% cat foo.h
extern int private;
static inline int f(void)
{
return private;
}
typedef int int32;
[yamato@x201]/tmp% u-ctags -o - /tmp/foo.h
# nothing is captured.
[yamato@x201]/tmp% u-ctags --languages=+OldC++ --language-force=OldC++ -o - /tmp/foo.h
f /tmp/foo.h /^static inline int f(void)$/;" f
int32 /tmp/foo.h /^typedef int int32;$/;" t
We can avoid this ignorance with modifying language map, however I hope u-ctags handling this situation well because this situation may be so popular.
@pragmaware, can I ask you to look at this one?
Done :) Waiting for checks to complete for merging.
I found another case in real code:
[yamato@x201]~/usr/pacemaker% cat /tmp/foo.h
typedef struct S {
int klass;
int class;
};
[yamato@x201]~/usr/pacemaker% u-ctags -o - /tmp/foo.h
S /tmp/foo.h /^typedef struct S {$/;" s
klass /tmp/foo.h /^ int klass;$/;" m struct:S typeref:typename:int
class is not recorded as a member.
I made a crazy input. gcc accepts this.
struct C {
int alignas;
int alignof;
int bool;
int catch;
int char16_t;
int char32_t;
int class;
int concept;
int constexpr;
int const_cast;
int decltype;
int delete;
int dynamic_cast;
int explicit;
int export;
int final;
int friend;
int mutable;
int namespace;
int new;
int noexcept;
int nullptr;
int operator;
int private;
int protected;
int public;
int reinterpret_cast;
int requires;
int static_assert;
int static_cast;
int template;
int this;
int thread_local;
int throw;
int try;
int typeid;
int typename;
int using;
int virutal;
};
How about adding `usedAsNameinC field in CXXKeywordDescriptor like:
typedef struct _CXXKeywordDescriptor
{
unsigned char bValidC;
const char * szName;
unsigned int uFlags;
boolean usedAsNameInC;
} CXXKeywordDescriptor;
@pragmaware, I woud like to try this.