Skip to content

Commit

Permalink
Fix macro object evaluation sometimes using wrong translation unit
Browse files Browse the repository at this point in the history
  • Loading branch information
lithiumtoast committed Jan 21, 2025
1 parent 0b8ec5a commit 2315410
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ int main(void)
}

var typeName = clangType.Spelling();
var mainTranslationUnit = clang.clang_Cursor_getTranslationUnit(info.ClangCursor);
var mainTranslationUnit = exploreContext.ParseContext.TranslationUnit;
var mainTranslationUnitCursor = clang.clang_getTranslationUnitCursor(mainTranslationUnit);

var clangCursorsInMainTranslationUnit = mainTranslationUnitCursor.GetDescendents(
Expand All @@ -182,8 +182,9 @@ static bool FindTypeName(string typeName, clang.CXCursor clangCursor)

if (clangCursorsInMainTranslationUnit.IsDefaultOrEmpty)
{
throw new ToolException(
var up = new ToolException(
$"Failed to find matching type in main translation unit for macro object '{macroName}'.");
throw up;
}

var clangCursorInMainTranslationUnit = clangCursorsInMainTranslationUnit.First();
Expand Down

0 comments on commit 2315410

Please sign in to comment.