[cfe-dev] clangd and deduced return types

Raymond Glover via cfe-dev cfe-dev at lists.llvm.org
Wed May 9 15:25:51 PDT 2018


Hello,

I have recently started clangd and had immediate success. However my
project has a dependency which makes good use of c++14 return type
deduction for functions, which when used create errors that prevent me from
using the "go to definition" feature in my IDE. Here is a minimal example
containing two files:

-- main.cpp --

#include "util.h"

template <typename T>
auto fooa(T a) { return a; }

int main() {
    fooa(0); // ok
    foob(0); // ok
    fooc(0); // error: function 'fooc<int>' with deduced
             // return type cannot be used before
             // it is defined
    return 0;
}

-- util.h --

template <typename T>
auto foob(T a) -> decltype(a) { return a; }

template <typename T>
auto fooc(T a) { return a; }

--

Is this a known limitation, or a bad configuration on my part? I'm using a
packaged version of clang-tools referencing svn331828.

Ray
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180509/40810359/attachment.html>


More information about the cfe-dev mailing list