Skip to content

Commit e751fba

Browse files
committed
Added exception handling when pathogen_GetArrangedFunction returns null.
Previously the PathogenArrangedFunction wrapper did not check if the function returned null, which meant you'd get a confusing NullReferenceException when accessing its members.
1 parent e3f92d5 commit e751fba

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

ClangSharp.Pathogen/PathogenArrangedFunction.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,12 @@ internal readonly struct RawArrangedFunction
3232
public ArgumentAccessor Arguments => new(Handle, checked((int)ArgumentCount));
3333

3434
public PathogenArrangedFunction(PathogenCodeGenerator codeGenerator, CXCursor cursor)
35-
=> Handle = PathogenExtensions.pathogen_GetArrangedFunction(codeGenerator.Handle, cursor);
35+
{
36+
Handle = PathogenExtensions.pathogen_GetArrangedFunction(codeGenerator.Handle, cursor);
37+
38+
if (Handle is null)
39+
{ throw new InvalidOperationException("Failed to arrange the function call. Use a debug build of libclang-pathogen for details."); }
40+
}
3641

3742
public PathogenArrangedFunction(PathogenCodeGenerator codeGenerator, FunctionDecl functionDecl)
3843
: this(codeGenerator, functionDecl.Handle)

external/llvm-project

0 commit comments

Comments
 (0)