Skip to content

Commit

Permalink
CPreProcessor,refactor: add kind parameter to doesCPreProRunAsStandal…
Browse files Browse the repository at this point in the history
…oneParser

doesCPreProRunAsStandaloneParser checks only HEADER kind to detect
wheter CPreProcessor parsers runs as standing-alone parser or not.

This change allows to refer MACRO kind for detecting.

Signed-off-by: Masatake YAMATO <[email protected]>
  • Loading branch information
masatake committed Oct 1, 2017
1 parent a8b3960 commit bd40ebd
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions parsers/cpreprocessor.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,19 @@ static bool popConditional (void)
return isIgnore ();
}

static bool doesCPreProRunAsStandaloneParser (int kind)
{
if (kind == CPREPRO_HEADER)
return (Cpp.headerKind == CPreProKinds + CPREPRO_HEADER);
else if (kind == CPREPRO_MACRO)
return (Cpp.defineMacroKind == CPreProKinds + CPREPRO_MACRO);
else
{
AssertNotReached();
return true;
}
}

static int makeDefineTag (const char *const name, const char* const signature, bool undef)
{
const bool isFileScope = (bool) (! isInputHeaderFile ());
Expand All @@ -591,7 +604,7 @@ static int makeDefineTag (const char *const name, const char* const signature, b
tagEntryInfo e;
int r;

if (Cpp.defineMacroKind == CPreProKinds + CPREPRO_MACRO)
if (doesCPreProRunAsStandaloneParser(CPREPRO_MACRO))
pushLanguage (Cpp.lang);

if (undef)
Expand All @@ -607,19 +620,14 @@ static int makeDefineTag (const char *const name, const char* const signature, b

r = makeTagEntry (&e);

if (Cpp.defineMacroKind == CPreProKinds + CPREPRO_MACRO)
if (doesCPreProRunAsStandaloneParser(CPREPRO_MACRO))
popLanguage ();

return r;
}
return CORK_NIL;
}

static bool doesCPreProRunAsStandaloneParser (void)
{
return (Cpp.headerKind == CPreProKinds + CPREPRO_HEADER);
}

static void makeIncludeTag (const char *const name, bool systemHeader)
{
tagEntryInfo e;
Expand All @@ -636,15 +644,15 @@ static void makeIncludeTag (const char *const name, bool systemHeader)
&& isXtagEnabled (XTAG_REFERENCE_TAGS)
&& Cpp.headerKind->roles [ role_index ].enabled)
{
if (doesCPreProRunAsStandaloneParser ())
if (doesCPreProRunAsStandaloneParser (CPREPRO_HEADER))
pushLanguage (Cpp.lang);

initRefTagEntry (&e, name, Cpp.headerKind, role_index);
e.isFileScope = false;
e.truncateLineAfterTag = true;
makeTagEntry (&e);

if (doesCPreProRunAsStandaloneParser ())
if (doesCPreProRunAsStandaloneParser (CPREPRO_HEADER))
popLanguage ();
}
}
Expand Down

0 comments on commit bd40ebd

Please sign in to comment.