[cfe-dev] clangd, completion in header files

Sam McCall via cfe-dev cfe-dev at lists.llvm.org
Fri Mar 30 11:47:37 PDT 2018


That's a good point. Somehow I forgot obj-c++ was a thing... We should
switch this.

One silly downside though - I find just "-x c++" won't actually give useful
results on real projects.
Does this match others' experience?
The "Unknown type name 'namespace'" error I tend to get from the current
behavior is at least predictable and recognizable. If we were parsing as
obj-c++ but missing other flags, problems could be more subtle.

But we could of course do even better here - if the CDB could report when a
command is fallback/inferred, clangd could insert a warning at the first
line of the file. "No compile flags found, using 'clang -x objective-c++'"
or so.

What do you think?

On Fri, Mar 30, 2018, 18:55 Duncan P. N. Exon Smith <dexonsmith at apple.com>
wrote:

>
> > On Mar 26, 2018, at 01:22, Sam McCall via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> >
> > When there's no compile command provided, we fall back to 'clang
> $filename'. Clang treats .h files as C.
>
> I wonder if, as a fallback, `clang -x objective-c++ $filename` would be
> more generally useful... it puts Clang into "accept almost everything"
> mode.  This is the mode LLDB uses for expression evaluation IIRC.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180330/ba7051af/attachment.html>


More information about the cfe-dev mailing list