mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Delay finishing the C++ translation unit until we reach the real EOF. (#6489)
Instead of parsing a complete C++ translation unit and then interacting with the translation unit further after the fact, delay finishing the translation unit until we finish the Carbon check phase. This fixes some issues where we would produce duplicated or incorrect diagnostics at the end of the C++ translation unit, particularly for unused declarations. Now we're in control of how we parse the translation unit, also disable parsing of C++20 modules if the syntax appears within `import Cpp inline` code. Keep the same clang parser alive throughout check, and use it instead of building a new one when parsing macros. This resolves issues where the translation unit scope was destroyed too early, resulting in unqualified lookup within macros being unable to find global scope entities. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
77caf3b9d8
commit
a8eca2ece6
@@ -1624,6 +1624,10 @@ static auto ImportVarDecl(Context& context, SemIR::LocId loc_id,
|
||||
// Finalize the `VarStorage` instruction.
|
||||
ReplaceInstBeforeConstantUse(context, var_storage_inst_id, var_storage);
|
||||
|
||||
// Inform Clang that the variable has been referenced.
|
||||
context.clang_sema().MarkVariableReferenced(GetCppLocation(context, loc_id),
|
||||
var_decl);
|
||||
|
||||
return var_storage_inst_id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user