Skip to content

Ownership Representation - #1099

Open
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:ownership-check
Open

Ownership Representation#1099
keremsahn wants to merge 1 commit into
compiler-research:mainfrom
keremsahn:ownership-check

Conversation

@keremsahn

Copy link
Copy Markdown
Contributor

Besides Alloc-DeallocType, a new added for representing functions ownership returns-takes behaviour based on ownership_... attributes, also added API for getting index of deallocated parameters for functions take ownership, and if it is specified another API is available to get which parameter decides the size of allocation for functions return ownership. Also some replacements that are not important.

@Vipul-Cariappa

@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.85%. Comparing base (9bbdbb2) to head (e5c9722).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1099      +/-   ##
==========================================
+ Coverage   87.74%   87.85%   +0.11%     
==========================================
  Files          23       23              
  Lines        6429     6489      +60     
==========================================
+ Hits         5641     5701      +60     
  Misses        788      788              
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOpTypes.h 97.02% <100.00%> (+0.09%) ⬆️
lib/CppInterOp/CppInterOp.cpp 90.70% <100.00%> (+0.15%) ⬆️
Files with missing lines Coverage Δ
include/CppInterOp/CppInterOpTypes.h 97.02% <100.00%> (+0.09%) ⬆️
lib/CppInterOp/CppInterOp.cpp 90.70% <100.00%> (+0.15%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '3' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1814: Calling 'GetOwnershipBitmask'

 INTEROP_TRACE(Fn);
                                                   ^

lib/CppInterOp/CppInterOp.cpp:1773: Taking false branch

ef Fn) {
           ^

lib/CppInterOp/CppInterOp.cpp:1775: Assuming 'D' is a 'CastReturnType'

p<clang::Decl>(Fn);
                                           ^

lib/CppInterOp/CppInterOp.cpp:1775: 'FD' is non-null

p<clang::Decl>(Fn);
                                      ^

lib/CppInterOp/CppInterOp.cpp:1775: Taking true branch

p<clang::Decl>(Fn);
                      ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Returns:' at line 1781

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1783: Execution continues on line 1778

rns;
             ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Holds:' at line 1787

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1787: Calling 'operator|'

nershipAttr::Holds:
                                     ^

include/CppInterOp/CppInterOpTypes.h:444: The value '3' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1814: Calling 'GetOwnershipBitmask'

 INTEROP_TRACE(Fn);
                                                   ^

lib/CppInterOp/CppInterOp.cpp:1773: Taking false branch

ef Fn) {
           ^

lib/CppInterOp/CppInterOp.cpp:1775: Assuming 'D' is a 'CastReturnType'

p<clang::Decl>(Fn);
                                           ^

lib/CppInterOp/CppInterOp.cpp:1775: 'FD' is non-null

p<clang::Decl>(Fn);
                                      ^

lib/CppInterOp/CppInterOp.cpp:1775: Taking true branch

p<clang::Decl>(Fn);
                      ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Returns:' at line 1781

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1783: Execution continues on line 1778

rns;
             ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Takes:' at line 1784

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1784: Calling 'operator|'

nershipAttr::Takes:
                                     ^

include/CppInterOp/CppInterOpTypes.h:444: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '6' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1814: Calling 'GetOwnershipBitmask'

 INTEROP_TRACE(Fn);
                                                   ^

lib/CppInterOp/CppInterOp.cpp:1773: Taking false branch

ef Fn) {
           ^

lib/CppInterOp/CppInterOp.cpp:1775: Assuming 'D' is a 'CastReturnType'

p<clang::Decl>(Fn);
                                           ^

lib/CppInterOp/CppInterOp.cpp:1775: 'FD' is non-null

p<clang::Decl>(Fn);
                                      ^

lib/CppInterOp/CppInterOp.cpp:1775: Taking true branch

p<clang::Decl>(Fn);
                      ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Takes:' at line 1784

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1786: Execution continues on line 1778

kes;
             ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Holds:' at line 1787

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1787: Calling 'operator|'

nershipAttr::Holds:
                                     ^

include/CppInterOp/CppInterOpTypes.h:444: The value '6' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '7' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1814: Calling 'GetOwnershipBitmask'

 INTEROP_TRACE(Fn);
                                                   ^

lib/CppInterOp/CppInterOp.cpp:1773: Taking false branch

ef Fn) {
           ^

lib/CppInterOp/CppInterOp.cpp:1775: Assuming 'D' is a 'CastReturnType'

p<clang::Decl>(Fn);
                                           ^

lib/CppInterOp/CppInterOp.cpp:1775: 'FD' is non-null

p<clang::Decl>(Fn);
                                      ^

lib/CppInterOp/CppInterOp.cpp:1775: Taking true branch

p<clang::Decl>(Fn);
                      ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Returns:' at line 1781

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1783: Execution continues on line 1778

rns;
             ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Takes:' at line 1784

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1786: Execution continues on line 1778

kes;
             ^

lib/CppInterOp/CppInterOp.cpp:1780: Control jumps to 'case Holds:' at line 1787

    switch (kind) {
    ^

lib/CppInterOp/CppInterOp.cpp:1787: Calling 'operator|'

nershipAttr::Holds:
                                     ^

include/CppInterOp/CppInterOpTypes.h:444: The value '7' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^

Comment thread lib/CppInterOp/CppInterOp.cpp Outdated
return INTEROP_RETURN(llvm::isa_and_nonnull<clang::FunctionProtoType>(T));
}

static OwnershipBehaviour GetOwnershipBitmask(ConstFuncRef Fn) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "Cpp::OwnershipBehaviour" is directly included [misc-include-cleaner]

nProtoType>(T));
                           ^

Comment on lines +813 to +821
def GetDeallocationIndexes : CppInterOpAPI {
let Doc = [{Returns the 0-based indices of the parameters whose ownership the
function takes or holds, as annotated by ownership_takes/ownership_holds.}];

let ReturnType = "std::vector<unsigned>";
let Args = [
Arg<"ConstFuncRef", "func">
];
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should return an int here.
If we still want to represent multiple arguments, we can represent them as a bit mask, where the nth LSB is 1 if the function takes ownership of the nth argument.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes makes sense

Comment thread lib/CppInterOp/CppInterOp.td Outdated
Comment on lines +786 to +811
def IsOwnershipReturns : CppInterOpAPI {
let Doc = "Checks whether the function is annotated with ownership_returns.";

let ReturnType = "bool";
let Args = [
Arg<"ConstFuncRef", "func">
];
}

def IsOwnershipTakes : CppInterOpAPI {
let Doc = "Checks whether the function is annotated with ownership_takes.";

let ReturnType = "bool";
let Args = [
Arg<"ConstFuncRef", "func">
];
}

def IsOwnershipHolds : CppInterOpAPI {
let Doc = "Checks whether the function is annotated with ownership_holds.";

let ReturnType = "bool";
let Args = [
Arg<"ConstFuncRef", "func">
];
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combine into one function:

OwnershipBehaviour GetOwnershipBehaviour(ConstFuncRef);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was how i started to implement, but that does not work. A function can both return ownership, take ownership of one argument and holds another one, so one attribute does not disable others. If I had implement something like GetOwnershipBehaviour I had to choose either first or last attribute in AST which makes no sense

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if you meant returning a bitmask that will probably work

Comment thread lib/CppInterOp/CppInterOp.cpp Outdated
return OwnershipBehaviour::Unknown;
const auto* D = unwrap<clang::Decl>(Fn);
if (const auto* FD = dyn_cast<FunctionDecl>(D)) {
OwnershipBehaviour result = OwnershipBehaviour::Unknown; // 0b000

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OwnershipBehaviour result = OwnershipBehaviour::Unknown; // 0b000
OwnershipBehaviour result = OwnershipBehaviour::Unknown;

?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to show it is 0 integral, acts as start point

Comment on lines +1765 to +1770
bool IsFunctionProtoType(ConstTypeRef TyRef) {
INTEROP_TRACE(TyRef);
QualType QT = QualType::getFromOpaquePtr(TyRef.data);
const auto* T = QT.getTypePtr();
return INTEROP_RETURN(llvm::isa_and_nonnull<clang::FunctionProtoType>(T));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we move this function?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be consistent, I implemented Isallocator in the wrong place at first, they should be adjacent with analyzers.

Comment on lines +345 to +349
inline QualKind operator|(QualKind a, QualKind b) {
return static_cast<QualKind>(static_cast<unsigned char>(a) |
static_cast<unsigned char>(b));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this required? Not used anywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is used

switch (kind) {
      case OwnershipAttr::Returns:
        result = result | OwnershipBehaviour::OwnershipReturns;
        break;
      case OwnershipAttr::Takes:
        result = result | OwnershipBehaviour::OwnershipTakes;
        break;

…ership returns-takes behaviour based on ownership_... attributes, also added API for getting index of deallocated parameters for functions take ownership, and if it is specified another API is available to get which parameter decides the size of allocation for functions return ownership. Also some replacements that are not important.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '3' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1779: Taking false branch

ACE(Fn);
           ^

lib/CppInterOp/CppInterOp.cpp:1781: Assuming 'D' is not a 'CastReturnType'

<clang::Decl>(Fn));
                                            ^

lib/CppInterOp/CppInterOp.cpp:1781: 'FTD' is null

<clang::Decl>(Fn));
                                      ^

lib/CppInterOp/CppInterOp.cpp:1781: Taking false branch

<clang::Decl>(Fn));
                      ^

lib/CppInterOp/CppInterOp.cpp:1783: Assuming 'D' is a 'CastReturnType'

getTemplatedDecl();
                                       ^

lib/CppInterOp/CppInterOp.cpp:1785: 'FD' is non-null

ecl>(D);
                ^

lib/CppInterOp/CppInterOp.cpp:1785: Taking false branch

ecl>(D);
           ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Holds:' at line 1797

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1801: Execution continues on line 1789

   break;
   ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Returns:' at line 1791

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1791: Calling 'operator|'

rshipAttr::Returns:
                                   ^

include/CppInterOp/CppInterOpTypes.h:444: The value '3' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1779: Taking false branch

ACE(Fn);
           ^

lib/CppInterOp/CppInterOp.cpp:1781: Assuming 'D' is not a 'CastReturnType'

<clang::Decl>(Fn));
                                            ^

lib/CppInterOp/CppInterOp.cpp:1781: 'FTD' is null

<clang::Decl>(Fn));
                                      ^

lib/CppInterOp/CppInterOp.cpp:1781: Taking false branch

<clang::Decl>(Fn));
                      ^

lib/CppInterOp/CppInterOp.cpp:1783: Assuming 'D' is a 'CastReturnType'

getTemplatedDecl();
                                       ^

lib/CppInterOp/CppInterOp.cpp:1785: 'FD' is non-null

ecl>(D);
                ^

lib/CppInterOp/CppInterOp.cpp:1785: Taking false branch

ecl>(D);
           ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Returns:' at line 1791

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1793: Execution continues on line 1789

turns;
             ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Takes:' at line 1794

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1794: Calling 'operator|'

nershipAttr::Takes:
                                   ^

include/CppInterOp/CppInterOpTypes.h:444: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1141: Control jumps to 'case 0:' at line 1142

ur;
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:77: expanded from macro 'GTEST_ASSERT_'

  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                 \
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/internal/gtest-port.h:732: expanded from macro 'GTEST_AMBIGUOUS_ELSE_BLOCKER_'

  switch (0)                          \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1141: Assuming the condition is true

ur;
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                       ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1141: Taking true branch

ur;
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1142: Control jumps to 'case 0:' at line 1143

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:77: expanded from macro 'GTEST_ASSERT_'

  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                 \
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/internal/gtest-port.h:732: expanded from macro 'GTEST_AMBIGUOUS_ELSE_BLOCKER_'

  switch (0)                          \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1142: Assuming the condition is true

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                       ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1142: Taking true branch

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1143: Control jumps to 'case 0:' at line 1144

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:77: expanded from macro 'GTEST_ASSERT_'

  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                 \
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/internal/gtest-port.h:732: expanded from macro 'GTEST_AMBIGUOUS_ELSE_BLOCKER_'

  switch (0)                          \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1143: Assuming the condition is true

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                       ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1143: Taking true branch

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1144: Control jumps to 'case 0:' at line 1145

s);
      ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:77: expanded from macro 'GTEST_ASSERT_'

  GTEST_AMBIGUOUS_ELSE_BLOCKER_                                 \
  ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/internal/gtest-port.h:732: expanded from macro 'GTEST_AMBIGUOUS_ELSE_BLOCKER_'

  switch (0)                          \
  ^

unittests/CppInterOp/FunctionReflectionTest.cpp:1145: Calling 'operator|'

e),
                ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest.h:1894: expanded from macro 'EXPECT_EQ'

  EXPECT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
                                                                    ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:143: expanded from macro 'EXPECT_PRED_FORMAT2'

  GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_NONFATAL_FAILURE_)
                                       ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:133: expanded from macro 'GTEST_PRED_FORMAT2_'

  GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
                                          ^

build/unittests/googletest-prefix/src/googletest/googletest/include/gtest/gtest_pred_impl.h:78: expanded from macro 'GTEST_ASSERT_'

  if (const ::testing::AssertionResult gtest_ar = (expression)) \
                                                   ^

include/CppInterOp/CppInterOpTypes.h:444: The value '5' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '6' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1779: Taking false branch

ACE(Fn);
           ^

lib/CppInterOp/CppInterOp.cpp:1781: Assuming 'D' is not a 'CastReturnType'

<clang::Decl>(Fn));
                                            ^

lib/CppInterOp/CppInterOp.cpp:1781: 'FTD' is null

<clang::Decl>(Fn));
                                      ^

lib/CppInterOp/CppInterOp.cpp:1781: Taking false branch

<clang::Decl>(Fn));
                      ^

lib/CppInterOp/CppInterOp.cpp:1783: Assuming 'D' is a 'CastReturnType'

getTemplatedDecl();
                                       ^

lib/CppInterOp/CppInterOp.cpp:1785: 'FD' is non-null

ecl>(D);
                ^

lib/CppInterOp/CppInterOp.cpp:1785: Taking false branch

ecl>(D);
           ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Holds:' at line 1797

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1801: Execution continues on line 1789

   break;
   ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Takes:' at line 1794

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1794: Calling 'operator|'

nershipAttr::Takes:
                                   ^

include/CppInterOp/CppInterOpTypes.h:444: The value '6' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^


inline OwnershipBehaviour operator|(OwnershipBehaviour A,
OwnershipBehaviour B) {
return static_cast<OwnershipBehaviour>(static_cast<unsigned char>(A) |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: The value '7' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour' [clang-analyzer-optin.core.EnumCastOutOfRange]

iour B) {
                   ^
Additional context

include/CppInterOp/CppInterOpTypes.h:434: enum declared here

alyze
                     ^

lib/CppInterOp/CppInterOp.cpp:1779: Taking false branch

ACE(Fn);
           ^

lib/CppInterOp/CppInterOp.cpp:1781: Assuming 'D' is not a 'CastReturnType'

<clang::Decl>(Fn));
                                            ^

lib/CppInterOp/CppInterOp.cpp:1781: 'FTD' is null

<clang::Decl>(Fn));
                                      ^

lib/CppInterOp/CppInterOp.cpp:1781: Taking false branch

<clang::Decl>(Fn));
                      ^

lib/CppInterOp/CppInterOp.cpp:1783: Assuming 'D' is a 'CastReturnType'

getTemplatedDecl();
                                       ^

lib/CppInterOp/CppInterOp.cpp:1785: 'FD' is non-null

ecl>(D);
                ^

lib/CppInterOp/CppInterOp.cpp:1785: Taking false branch

ecl>(D);
           ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Holds:' at line 1797

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1801: Execution continues on line 1789

   break;
   ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Returns:' at line 1791

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1793: Execution continues on line 1789

turns;
             ^

lib/CppInterOp/CppInterOp.cpp:1789: Control jumps to 'case Takes:' at line 1794

OwnershipAttr>()) {
                        ^

lib/CppInterOp/CppInterOp.cpp:1794: Calling 'operator|'

nershipAttr::Takes:
                                   ^

include/CppInterOp/CppInterOpTypes.h:444: The value '7' provided to the cast expression is not in the valid range of values for 'OwnershipBehaviour'

iour B) {
                   ^

return INTEROP_RETURN(llvm::isa_and_nonnull<clang::FunctionProtoType>(T));
}

OwnershipBehaviour GetOwnershipBehaviour(ConstFuncRef Fn) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: no header providing "Cpp::OwnershipBehaviour" is directly included [misc-include-cleaner]

nProtoType>(T));
                    ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants