Skip to content

Conversation

@j-hui
Copy link
Contributor

@j-hui j-hui commented Dec 12, 2025

No description provided.

getClangOwningModule() no longer takes a parameter named `MI` nor does
it return an optional (it just returns a poitner).
This refactoring restructures the code in a couple of ways:

- move all the "conformToXXXIfNeeded()" functions into a single function
  and remove them from the ClangDerivedConformances.h interface
- unify the check for isInStdNamespace() for the C++ stdlib types
- unify the name comparisons into a single llvm::StringSwitch
- unify redundant nullptr assert()s, and upgrade them to ASSERT()
- move the known stdlib type name-checking logic out of the
  "conformToCxxSTDLIBTYPEIfNeeded()" functions, and rename them to drop
  the "IfNeeded" suffix.

This patch also introduces a local CxxStdType enum class that enumerates
(and thus documents) all of the known (and thus supported) types from
the C++ stdlib types.

The ultimate goal is to organize the code such that by the time we call
"conformToCxxSTDLIBTYPE()" we are already sure that the type is (or at
least claims to be, based on its name and DeclContext) the C++ stdlib
type we think it is, rather than interleaving such checks with the
conformance synthesis logic.

The main observable difference should be the logging: now, we will no
longer have PrettyStackTraceDecls logging for C++ stdlib types like
"conforming to CxxVector" unless we are already certain we are looking
at a relevant type, e.g., std::vector.

Otherwise, the functional behavior of this code should be the same as
before.
@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2025

@swift-ci please test

@j-hui j-hui force-pushed the clang-lookups-for-clang-conformances branch from c664a65 to 7c779a1 Compare December 12, 2025 06:28
This is the first patch of a series of patches intended to shift lookup
toward using Clang lookup, to avoid Swift lookup's dependency on eager
Clang member importation.

The lookupCxxTypeMember() helper function replaces the previous helper
function, lookupNestedClangTypeDecl(). Functionally, the main difference
is that lookupCxxTypeMember() uses clang::Sema::LookupQualifiedName(),
which takes cares of issues like inheritance, ambiguity, etc. Meanwhile,
lookupNestedClangTypeDecl() only used clang::DeclContext::lookup(),
which is limited to the lexical context, and does not work with
inheritance.

The isIterator() function is renamed to hasIteratorConcept() to better
reflect what it is checking, and still uses clang::DeclContext::lookup()
to preserve the original behavior and to avoid requiring its callers to
supply a clang::Sema instance.
@j-hui j-hui force-pushed the clang-lookups-for-clang-conformances branch from 7c779a1 to 6ed9efb Compare December 12, 2025 19:29
@j-hui
Copy link
Contributor Author

j-hui commented Dec 12, 2025

@swift-ci please test

@j-hui
Copy link
Contributor Author

j-hui commented Dec 13, 2025

@swift-ci please test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant