Skip to content

Commit

Permalink
Correctly parse C++ headers as headers
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasleibner committed Mar 20, 2024
1 parent 195cfeb commit 757f928
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/clangparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ void ClangTUParser::parse()
// we use the source file to detected the language. Detection will fail if you
// pass a bunch of .h files containing ObjC code, and no sources :-(
SrcLangExt lang = getLanguageFromFileName(fileName);
QCString fn = fileName.lower();
if (lang==SrcLangExt::ObjC || p->detectedLang!=DetectedLang::Cpp)
{
QCString fn = fileName.lower();
if (p->detectedLang!=DetectedLang::Cpp &&
(fn.endsWith(".cpp") || fn.endsWith(".cxx") ||
fn.endsWith(".cc") || fn.endsWith(".c")))
Expand All @@ -200,7 +200,13 @@ void ClangTUParser::parse()
}
switch (p->detectedLang)
{
case DetectedLang::Cpp: argv.push_back(qstrdup("c++")); break;
case DetectedLang::Cpp:
if (fn.endsWith(".hpp") || fn.endsWith(".hxx") ||
fn.endsWith(".hh") || fn.endsWith(".h"))
argv.push_back(qstrdup("c++-header"));
else
argv.push_back(qstrdup("c++"));
break;
case DetectedLang::ObjC: argv.push_back(qstrdup("objective-c")); break;
case DetectedLang::ObjCpp: argv.push_back(qstrdup("objective-c++")); break;
}
Expand Down

0 comments on commit 757f928

Please sign in to comment.