FunctionDecl::getBody() returning nullptr
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 19 08:33:00 PDT 2015
When I run the following test code through clang-tidy -checks=*, I get
a crash from some relatively strange behavior with FunctionDecl.
template <class T> struct remove_reference {typedef T type;};
template <class T> struct remove_reference<T&> {typedef T type;};
template <class T> struct remove_reference<T&&> {typedef T type;};
template <typename T>
typename remove_reference<T>::type&& move(T&& arg) {
return static_cast<typename remove_reference<T>::type&&>(arg);
}
AnalysisConsumer::getModeForDecl() is called, and it has code that
does: D->hasBody() ? D->getBody()->stuff : stuff;
What's strange is that hasBody() returns true, but getBody() returns
nullptr. I don't think that this should be possible. I'm wondering
whether it's purposeful that hasBody() does not check
Definition->Body?
Also, the FunctionDecl in question is for move(), which does have a
body, so I do not understand why the definition would claim there is
no body.
Ideas, or should I file a bug report?
~Aaron
More information about the cfe-commits
mailing list