From 44172d2239305f1a44665cffa95abaffc1465624 Mon Sep 17 00:00:00 2001 From: triton Date: Wed, 7 May 2014 15:07:58 +0100 Subject: [PATCH] Do not check for duplicates when handling preprocessed entities. Even though they share the same original ptr to clang's PreprocessedEntity, they can still have different locations so we need to duplicate them when converting the AST. --- src/Core/Parser/ASTConverter.cs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/Core/Parser/ASTConverter.cs b/src/Core/Parser/ASTConverter.cs index 30259c37..8803e982 100644 --- a/src/Core/Parser/ASTConverter.cs +++ b/src/Core/Parser/ASTConverter.cs @@ -599,8 +599,9 @@ namespace CppSharp // Check if the declaration was already handled and return its // existing instance. - if (Declarations.ContainsKey(originalPtr)) - return Declarations[originalPtr]; + if (CheckForDuplicates(decl)) + if (Declarations.ContainsKey(originalPtr)) + return Declarations[originalPtr]; var newDecl = base.Visit(decl); return newDecl; @@ -674,12 +675,18 @@ namespace CppSharp } } + bool CheckForDuplicates(Declaration decl) + { + return !(decl is PreprocessedEntity); + } + void VisitDeclaration(Declaration decl, AST.Declaration _decl) { var originalPtr = new IntPtr(decl.OriginalPtr); - if (Declarations.ContainsKey(originalPtr)) - throw new NotSupportedException("Duplicate declaration processed"); + if (CheckForDuplicates(decl)) + if (Declarations.ContainsKey(originalPtr)) + throw new NotSupportedException("Duplicate declaration processed"); // Add the declaration to the map so that we can check if have // already handled it and return the declaration.