[PATCH] D52273: [clangd] Initial implementation of expected types
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 24 10:03:15 PDT 2018
ilya-biryukov added inline comments.
================
Comment at: clangd/ExpectedTypes.h:68
+
+/// Represents a type of partially applied conversion. Should be treated as an
+/// opaque value and can only be used to check whether the types are converible
----------------
sammccall wrote:
> this represents a type (in the c++ sense), not a conversion, right?
It's an "expression" with an extra data with some extra data (whether the user conversion was applied to get this expression)
================
Comment at: clangd/ExpectedTypes.h:82
+ static llvm::SmallVector<SType, 2>
+ fromCompletionResult(ASTContext &Ctx, const CodeCompletionResult &R);
+
----------------
sammccall wrote:
> coupling to CompletionResult seems premature here, can we stick to passing getExpectedType() until we know that abstraction needs to be broken?
There's some useful logic that is tied to completion results, e.g. to extract function return type `CompletionResult`.
Happy to accept a decl, but would keep the name `fromCompletionResult`. Does that LG?
================
Comment at: clangd/ExpectedTypes.h:213
+
+void collectConvertibleFrom(ASTContext &Ctx, MockExpr Source,
+ llvm::function_ref<void(PartialConv)> OutF);
----------------
sammccall wrote:
> sammccall wrote:
> > why is implementing one of these directions not enough?
> >
> > It should probably be:
> > As far as I can tell, derived-to-base is the tricky one here: it's an important conversion (albeit one we should leave out of the first patch), and you can't ask "what's convertible to base" since the answer is an open set you can't see.
> >
> > So it seems the minimal set you need for handling pointer to base is `Type getRepresentative(Type)` and `set<Type> getRepresentativesAfterConversion(Type)` or so...
> names are unclear: is `collectConvertibleFrom(T)` the convertible-from types for T (i.e the types T is convertible from), or the types that are convertible from T?
Derived-to-base and user conversions.
We can't enumerate all derived classes for some type, so instead need to enumerate all bases when adding a symbol to the index.
We can't enumerate all types that have user-defined conversions to some type T, so we need to enumerate all user-defined conversions when adding a symbol instead.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D52273
More information about the cfe-commits
mailing list