Skip to content

Commit 6a007e6

Browse files
committed
Implement basic support for parsing function-like macros.
1 parent 7b77d84 commit 6a007e6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/CppParser/Parser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3509,7 +3509,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity(
35093509

35103510
MacroInfo* MI = P.getMacroInfo((IdentifierInfo*)II);
35113511

3512-
if (!MI || MI->isBuiltinMacro() || MI->isFunctionLike())
3512+
if (!MI || MI->isBuiltinMacro())
35133513
break;
35143514

35153515
clang::SourceManager& SM = c->getSourceManager();

src/Generator.Tests/AST/TestAST.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,5 +637,15 @@ public void TestCompletionSpecializationInFunction()
637637
function.ReturnType.Type.TryGetClass(out Class specialization);
638638
Assert.That(specialization.IsIncomplete, Is.False);
639639
}
640+
641+
[Test]
642+
public void TestPreprocessedEntities()
643+
{
644+
var unit = AstContext.TranslationUnits.First(u => u.FileName == "AST.h");
645+
var macro = unit.PreprocessedEntities.OfType<MacroDefinition>()
646+
.FirstOrDefault(exp => exp.Name == "MACRO");
647+
Assert.NotNull(macro);
648+
Assert.AreEqual("(x, y, z) x##y##z", macro.Expression);
649+
}
640650
}
641651
}

tests/Native/AST.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,5 @@ __attribute__((deprecated)) int deprecated_func(int num);
251251
int non_deprecated_func(int num);
252252

253253
TestTemplateClass<double> returnIncompleteTemplateSpecialization();
254+
255+
#define MACRO(x, y, z) x##y##z

0 commit comments

Comments
 (0)