-
Notifications
You must be signed in to change notification settings - Fork 138
clang-21 support #289
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
Open
bmwalters
wants to merge
5
commits into
csmith-project:master
Choose a base branch
from
bmwalters:clang-21
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
clang-21 support #289
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- **Line 7086-7089**: Stores `NestedNameSpecifier *NNS` and `const IdentifierInfo *Name` as separate membe rs - **Line 7098-7099**: Provides `getQualifier()` and `getIdentifier()` methods - **Line 7258**: Now stores a single `DependentTemplateStorage Name` member (instead of separate NNS and I dentifierInfo) - **Line 7266-7268**: Provides `getDependentTemplateName()` method that returns `const DependentTemplateSt orage&` - **Removed**: `getQualifier()` and `getIdentifier()` methods are gone The `DependentTemplateStorage` class (defined in TemplateName.h:582-621) provides: - `getQualifier()` → returns `NestedNameSpecifier*` - `getName()` → returns `IdentifierOrOverloadedOperator` The `IdentifierOrOverloadedOperator` struct (TemplateName.h:545-572) provides: - `getIdentifier()` → returns `const IdentifierInfo*` The failing code at CommonRenameClassRewriteVisitor.h:313: ```cpp const IdentifierInfo *IdInfo = DTST->getIdentifier(); ``` Should be changed to: ```cpp const IdentifierInfo *IdInfo = DTST->getDependentTemplateName().getName().getIdentifier(); ``` This chains the new API calls: 1. `getDependentTemplateName()` returns the `DependentTemplateStorage` 2. `getName()` returns the `IdentifierOrOverloadedOperator` 3. `getIdentifier()` returns the `const IdentifierInfo*`
The enum has **6 values**: - Line 79-102: `Identifier`, `Namespace`, `NamespaceAlias`, `TypeSpec`, **`TypeSpecWithTemplate`**, `Globa l`, `Super` - Line 52-56: Storage enum includes `StoredTypeSpec = 2` and `StoredTypeSpecWithTemplate = 3` The enum has **5 values** (one removed): - Line 78-97: `Identifier`, `Namespace`, `NamespaceAlias`, `TypeSpec`, `Global`, `Super` - **`TypeSpecWithTemplate` was removed** - Line 52-55: Storage enum only has `StoredTypeSpec = 2` (no `StoredTypeSpecWithTemplate`) In LLVM 21, the distinction between `TypeSpec` and `TypeSpecWithTemplate` was eliminated. The `template` k eyword information is now stored differently (likely in the `TypeLoc` or associated location information r ather than in the specifier kind). Since both cases were doing the same thing (calling `TraverseTypeLoc`), and LLVM 21 merged them into a sin gle `TypeSpec` case, simply removing the `TypeSpecWithTemplate` case is the correct fix. The functionality remains the same because type specs with or without template keywords now both use the `TypeSpec` enum va lue.
The following kernel attributes existed: - `OpenCLKernelAttr` - for OpenCL kernels - `NVPTXKernelAttr` - for NVIDIA PTX kernels - `SYCLKernelAttr` - for SYCL kernels The attribute system was refactored: - **`OpenCLKernelAttr` was removed** - **`NVPTXKernelAttr` was removed** - Replaced with a unified `DeviceKernelAttr` attribute - `SYCLKernelEntryPointAttr` exists for SYCL-specific entry points LLVM 21 consolidated the various kernel attributes (`OpenCLKernelAttr`, `NVPTXKernelAttr`, etc.) into a si ngle unified `DeviceKernelAttr` that works across different device programming models (OpenCL, CUDA, etc.) . This change reflects the consolidation of kernel attributes in LLVM 21. The `DeviceKernelAttr` now covers what `OpenCLKernelAttr` (and other kernel attributes) used to represent. **Purpose**: The code is checking if a function is a kernel function that should not be removed even if it appears unused, since kernel functions are entry points called by the runtime. The new `DeviceKernelAttr` serves this same purpose across all device programming models.
The deprecated `getDirectory()` method that returned `ErrorOr<const DirectoryEntry *>` was removed in LLVM 21. The migration path is to use `getOptionalDirectoryRef()` which returns an `OptionalDirectoryEntryRef`. **Why this works**: - The original code checks the boolean value of the `ErrorOr` result (true if directory exists, false otherwise) - The new code checks the boolean value of the `OptionalDirectoryEntryRef` (true if directory exists, false otherwise) - Both support implicit conversion to bool in the same way, so the logic remains identical
**LLVM 20 & 21 (CompilerInvocation.h:80)**: - `TargetOpts` is a **protected** member in `CompilerInvocationBase` - Direct access like `.TargetOpts` is not allowed from outside the class **Solution**: Use the public getter method `getTargetOpts()` instead of direct member access **LLVM 20 (TargetInfo.h:305-306)**: - Signature: `CreateTargetInfo(DiagnosticsEngine &Diags, const std::shared_ptr<TargetOptions> &Opts)` - Accepts a `std::shared_ptr<TargetOptions>` (shared pointer) **LLVM 21 (TargetInfo.h:316-317)**: - Signature: `CreateTargetInfo(DiagnosticsEngine &Diags, TargetOptions &Opts)` - Accepts a `TargetOptions &` (reference) 1. The code was directly accessing the protected member `TargetOpts` instead of using the public getter 2. The `CreateTargetInfo` API changed from accepting a `shared_ptr` to accepting a reference **Why this works**: 1. `getTargetOpts()` is a public method (defined at line 250 in `CompilerInvocation`) that returns `TargetOptions &` 2. This matches the new LLVM 21 signature that expects `TargetOptions &` instead of `std::shared_ptr<TargetOptions>` 3. The getter dereferences the shared_ptr internally (`return *TargetOpts`), providing the reference that the new API needs
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
split into patches for review:
Depends on #285 and #287 to get a working build.
I chose not to stack on them since the patches commute.