mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 12:31:04 +01:00
Formalize Cpp as a PackageNameId (#6306)
This turns `Cpp` into a keyword, and makes it map to `NameId::Cpp` and `PackageNameId::Cpp`. Per discussion with zygoloid, the keyword versus identifier question is deliberately kept open by #4846. This PR switches to a keyword because mapping to a specific `PackageNameId` works best with a special `NameId` not backed by an `IdentifierId`. We could in theory make it work using `IdentifierId` or a runtime-tracked `PackageNameId` for `Cpp` (e.g. stored on `SemIR::File`), but this approach is consistent with `Core` and so seemed like a good starting point. --------- Co-authored-by: Dana Jansens <danakj@orodu.net>
This commit is contained in:
co-authored by
Dana Jansens
parent
ae50e0f623
commit
8166f9a7cf
@@ -76,17 +76,17 @@ int n;
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportBody', text: ';', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportSpecifier', text: 'inline', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', has_error: yes, subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportBody', text: 'library', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportSpecifier', text: 'inline', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', has_error: yes, subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'LibraryName', text: '"foo.h"'},
|
||||
// CHECK:STDOUT: {kind: 'LibrarySpecifier', text: 'library', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', has_error: yes, subtree_size: 5},
|
||||
@@ -100,7 +100,7 @@ int n;
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportBody', text: '', has_error: yes},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportSpecifier', text: 'inline', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'ImportDecl', text: 'inline', has_error: yes, subtree_size: 5},
|
||||
@@ -136,12 +136,12 @@ int n;
|
||||
// CHECK:STDOUT: parse_tree: [
|
||||
// CHECK:STDOUT: {kind: 'FileStart', text: ''},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportBody', text: '"int m;"'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportSpecifier', text: 'inline', subtree_size: 2},
|
||||
// CHECK:STDOUT: {kind: 'ImportDecl', text: ';', subtree_size: 5},
|
||||
// CHECK:STDOUT: {kind: 'ImportIntroducer', text: 'import'},
|
||||
// CHECK:STDOUT: {kind: 'IdentifierPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'CppPackageName', text: 'Cpp'},
|
||||
// CHECK:STDOUT: {kind: 'InlineImportBody', text: ''''
|
||||
// CHECK:STDOUT: // C++ comment.
|
||||
// CHECK:STDOUT: int n;
|
||||
|
||||
Reference in New Issue
Block a user