Repository navigation
fix(modules): build test PCMs and use AST import tokens #429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -63,13 +63,11 @@ class SemanticVisitor : public FilteredASTVisitor<SemanticVisitor<Derived>> { | |||||
|
|
||||||
| /// Invoked when a module occurrence is seen in source code. | ||||||
| /// @param keyword The location of the `module` or `import` keyword. | ||||||
| /// @param identifiers Tokens that make up the module name. | ||||||
| /// @param identifiers Source locations of identifiers that make up the module name. | ||||||
| void handleModuleOccurrence(clang::SourceLocation keyword, | ||||||
| llvm::ArrayRef<clang::syntax::Token> identifiers) { | ||||||
| llvm::ArrayRef<clang::SourceLocation> identifiers) { | ||||||
| assert(keyword.isValid() && keyword.isFileID() && "Invalid keyword location"); | ||||||
|
||||||
| assert(keyword.isValid() && keyword.isFileID() && "Invalid keyword location"); | |
| assert(keyword.isValid() && "Invalid keyword location"); |
Copilot
AI
Apr 19, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VisitImportDecl searches for the import keyword by comparing token.text(...) == "import". This is more fragile and slower than checking the token kind (e.g., token.kind() == clang::tok::kw_import), and avoids depending on SourceManager text extraction for each token.
| if(token.text(unit.context().getSourceManager()) == "import") { | |
| if(token.kind() == clang::tok::kw_import) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid turning duplicate
importkeyword tokens intoConflict.Line 247 can emit the same
Keywordrange already produced by the lexical pass;merge_tokens()then treats same-range non-directive duplicates asSymbolKind::Conflict. Preserve identical kinds when resolving conflicts, or avoid emitting the duplicate keyword here.🐛 Proposed fix: preserve identical token kinds during merge
static void resolve_conflict(RawToken& last, const RawToken& current) { if(last.kind == SymbolKind::Conflict) { return; } + if(last.kind == current.kind) { + last.modifiers |= current.modifiers; + return; + } // Directive is a low-priority lexical kind; semantic tokens override it. if(last.kind == SymbolKind::Directive) { last = current; return; }🤖 Prompt for AI Agents