llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.84k stars 11.47k forks source link

Diagnostic doesn't include interesting template instantiation location #20826

Open nico opened 10 years ago

nico commented 10 years ago
Bugzilla Link 20452
Version trunk
OS All
CC @DougGregor,@zygoloid,@rnk

Extended Description

I got this diagnostic:

..\..\third_party\WebKit\Source\wtf/PassRefPtr.h(57,16) :  error(clang): member access into incomplete type 'blink::SQLTransactionBackend'
            ptr->deref();
               ^
..\..\third_party\WebKit\Source\wtf/RefPtr.h(59,35) :  note(clang): in instantiation of function template specialization 'WTF::derefIfNotNull<blink::SQLTransactionBackend>' requested here
        ALWAYS_INLINE ~RefPtr() { derefIfNotNull(m_ptr); }
                                  ^
..\..\third_party\WebKit\Source\wtf/Vector.h(64,23) :  note(clang): in instantiation of member function 'WTF::RefPtr<blink::SQLTransactionBackend>::~RefPtr' requested here
                cur->~T();
                      ^
..\..\third_party\WebKit\Source\wtf/Vector.h(247,69) :  note(clang): in instantiation of member function 'WTF::VectorDestructor<true, WTF::RefPtr<blink::SQLTransactionBackend> >::destruct' requested here
            VectorDestructor<VectorTraits<T>::needsDestruction, T>::destruct(begin, end);
                                                                    ^
..\..\third_party\WebKit\Source\wtf/Deque.h(250,29) :  note(clang): in instantiation of member function 'WTF::VectorTypeOperations<WTF::RefPtr<blink::SQLTransactionBackend> >::destruct' requested here
            TypeOperations::destruct(m_buffer.buffer() + m_start, m_buffer.buffer() + m_end);
                            ^
..\..\third_party\WebKit\Source\wtf/Deque.h(270,13) :  note(clang): in instantiation of member function 'WTF::Deque<WTF::RefPtr<blink::SQLTransactionBackend>, 0, WTF::DefaultAllocator>::destroyAll' requested here
            destroyAll();
            ^
..\..\third_party\WebKit\Source\wtf/Vector.h(519,64) :  note(clang): in instantiation of member function 'WTF::Deque<WTF::RefPtr<blink::SQLTransactionBackend>, 0, WTF::DefaultAllocator>::finalize' requested here
        ~VectorDestructorBase() { static_cast<Derived*>(this)->finalize(); }
                                                               ^
..\..\third_party\WebKit\Source\wtf/Deque.h(46,11) :  note(clang): in instantiation of member function 'WTF::VectorDestructorBase<WTF::Deque<WTF::RefPtr<blink::SQLTransactionBackend>, 0, WTF::DefaultAllocator>, WTF::RefPtr<blink::SQLTransactionBackend>, false, false>::~VectorDestructorBase' requested here
    class Deque : public VectorDestructorBase<Deque<T, inlineCapacity, Allocator>, T, (inlineCapacity > 0), Allocator::isGarbageCollected> {
          ^
..\..\third_party\WebKit\Source\modules/webdatabase/DatabaseBackendBase.h(96,18) :  note(clang): forward declaration of 'blink::SQLTransactionBackend'
    friend class SQLTransactionBackend;
                 ^
1 error generated.

I think the fix is to make the destructor of a class explicit that isn't mentioned in the diagnostic at all (the class that has a Deque<SQLTransactionBackend> as member).

cfd43508-abed-4b61-9716-b28c9ef59019 commented 2 years ago

mentioned in issue llvm/llvm-bugzilla-archive#46000

ec04fc15-fa35-46f2-80e1-5d271f2ef708 commented 10 years ago

I already have a patch for this; just need to clean it up and check it in. (The problem is that delaying function template instantiation causes us to lose the "in implicit definition of special member function" context.)

FWIW, while this may be fine in this case, in the general case you get a diagnostic where all source locations are in system headers, with no indication of how you got there. We really need the extra note for that case...

rnk commented 10 years ago

I think this error message is OK for an unsophisticated user. A valid fix is to merely include the header for SQLTransationBackend, and this is probably what most people do. In our Blink fixes, we're being a bit clever and realizing that we can avoid the compile time hit of header bloat by adding an out-of-line dtor in the .cpp file.

A note about in implicit virtual destructor for 'DatabaseBackend' would be nice, but we've also already got quite a few notes here.

nico commented 10 years ago

I think this is the fix for this diagnostic. Note that the files touched in that change aren't listed in the compiler output.

nico commented 10 years ago

assigned to @zygoloid