Since we now handle functions without a body as well, we can't just use getHasBody() anymore. Funtions that haven't been defined yet are those that don't have a body *and* aren't valid.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Just get the information whether the Function has a body directly from the FunctionDecl. This fixes referencing member functions that are defined later.
clang/test/AST/Interp/functions.cpp | ||
---|---|---|
166–182 | Should we have some similar tests involving free functions as well? Also, how does BodylessMemberFunction differ from F? They both look to be testing the same thing aside from return types. Should we have a test that involves a defaulted special member function that is called explicitly? e.g., https://godbolt.org/z/nzjEcPMKG (Clang is correct here, GCC fails to catch the UB). |
clang/test/AST/Interp/functions.cpp | ||
---|---|---|
166–182 | We have a test for free-standing functions already higher up: constexpr int f(); // expected-note {{declared here}} \ // ref-note {{declared here}} [...] constexpr int a() { return f(); } constexpr int f() { return 5; } static_assert(a() == 5, ""); I think the two used to test something different, but now they test the same thing, yes. I'll remove one of them.
That is also caught but the diagnostics are in the wrong place (and slightly different. The old interpreter emits "destruction of dereferenced null pointer" while the new one does "member call on dereferenced null pointer"). |
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
1468 | Why the check for isContexpr()? |
clang/lib/AST/Interp/ByteCodeExprGen.cpp | ||
---|---|---|
1468 | isConstexpr() just returns whether the function is valid (i.e. was compiled successfully). hasBody() can still return false for a valid function, if the funcdecl had no body. |
Why the check for isContexpr()?