mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-25 05:52:36 +00:00
Fix exporting of names to C++ after a lookup failure. (#7933)
If Clang encounters a lookup failure, it caches that result, creating problems with `-share-cpp-ast` where a lookup failure in one file effectively poisons the same name when looked up in a different file. Also, if Clang triggers loading a complete name table (which happens, for example, during typo correction, but Clang could do that any time it wants to), it clears out the "has external visible results" flag, which means that introducing new names in Carbon and then attempting to use them from C++ after that point does not work. Fix both of these problems by re-enabling the "has external visible results" flag on callbacks that indicate Clang just cleared it, and by not caching failed name lookups into Carbon scopes in Clang's lookup table. (They still get cached in *our* lookup table.) Assisted-by: Gemini via Antigravity
This commit is contained in:
1 parent
a045da8e67
commit
e476a2bd3b
6 files changed
+293
-29
No files matched your search
@@ -73,9 +73,9 @@ auto Class::GetStructTypeFields(const File& sem_ir,
|
||||
|
||||
auto GetAsCarbonOwnedClass(const File& sem_ir, const clang::TagDecl* tag_decl)
|
||||
-> std::optional<std::pair<SemIR::TypeId, SemIR::ClassType>> {
|
||||
// Quickly check whether we could possibly own this class.
|
||||
// TODO: Once we multiplex with the ASTReader, handle
|
||||
// ASTReader::completeVisibleDeclsMap setting this to `false`.
|
||||
// Quickly check whether we could possibly own this class. Carbon-owned
|
||||
// classes always have external visible storage (preserved across
|
||||
// `ASTReader::completeVisibleDeclsMap` by `ReadOnlyASTSource`).
|
||||
if (!tag_decl->hasExternalVisibleStorage()) {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user