Browse Source

Implement basic support for parsing function-like macros.

pull/1352/head
João Matos 5 years ago committed by João Matos
parent
commit
6a007e6d60
  1. 2
      src/CppParser/Parser.cpp
  2. 10
      src/Generator.Tests/AST/TestAST.cs
  3. 2
      tests/Native/AST.h

2
src/CppParser/Parser.cpp

@ -3509,7 +3509,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity( @@ -3509,7 +3509,7 @@ PreprocessedEntity* Parser::WalkPreprocessedEntity(
MacroInfo* MI = P.getMacroInfo((IdentifierInfo*)II);
if (!MI || MI->isBuiltinMacro() || MI->isFunctionLike())
if (!MI || MI->isBuiltinMacro())
break;
clang::SourceManager& SM = c->getSourceManager();

10
src/Generator.Tests/AST/TestAST.cs

@ -637,5 +637,15 @@ namespace CppSharp.Generator.Tests.AST @@ -637,5 +637,15 @@ namespace CppSharp.Generator.Tests.AST
function.ReturnType.Type.TryGetClass(out Class specialization);
Assert.That(specialization.IsIncomplete, Is.False);
}
[Test]
public void TestPreprocessedEntities()
{
var unit = AstContext.TranslationUnits.First(u => u.FileName == "AST.h");
var macro = unit.PreprocessedEntities.OfType<MacroDefinition>()
.FirstOrDefault(exp => exp.Name == "MACRO");
Assert.NotNull(macro);
Assert.AreEqual("(x, y, z) x##y##z", macro.Expression);
}
}
}

2
tests/Native/AST.h

@ -251,3 +251,5 @@ __attribute__((deprecated)) int deprecated_func(int num); @@ -251,3 +251,5 @@ __attribute__((deprecated)) int deprecated_func(int num);
int non_deprecated_func(int num);
TestTemplateClass<double> returnIncompleteTemplateSpecialization();
#define MACRO(x, y, z) x##y##z

Loading…
Cancel
Save