diff options
author | erichkeane <ekeane@nvidia.com> | 2025-03-07 08:04:02 -0800 |
---|---|---|
committer | erichkeane <ekeane@nvidia.com> | 2025-03-07 08:05:19 -0800 |
commit | 67960e5c08629bb78c147bd0a86764967448b33c (patch) | |
tree | 4dfaa8517c83c477226fd7bdb4ef0e5477fa9e6f /clang/lib | |
parent | 5685def507ed7c95bf93572e5cf8c30efbc7d99b (diff) | |
download | llvm-67960e5c08629bb78c147bd0a86764967448b33c.zip llvm-67960e5c08629bb78c147bd0a86764967448b33c.tar.gz llvm-67960e5c08629bb78c147bd0a86764967448b33c.tar.bz2 |
[OpenACC] Ensure decl OpenACC constructs don't crash
I initially implemented codegen to be a 'no-op' for these declarations,
which I thought was properly implemented. However, when they are a
top-level decl, we have a separate switch. This patch makes sure they
are properly emitted at top-level as a no-op, and adds a test for both
top-level and not top-level.
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 | ||||
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.h | 6 |
2 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index bca0a93..d2c97ce 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -7300,6 +7300,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) { getHLSLRuntime().addBuffer(cast<HLSLBufferDecl>(D)); break; + case Decl::OpenACCDeclare: + EmitOpenACCDeclare(cast<OpenACCDeclareDecl>(D)); + break; + case Decl::OpenACCRoutine: + EmitOpenACCRoutine(cast<OpenACCRoutineDecl>(D)); + break; + default: // Make sure we handled everything we should, every other kind is a // non-top-level decl. FIXME: Would be nice to have an isTopLevelDeclKind diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h index 83bb5bc..e7c9238 100644 --- a/clang/lib/CodeGen/CodeGenModule.h +++ b/clang/lib/CodeGen/CodeGenModule.h @@ -1574,9 +1574,11 @@ public: CodeGenFunction *CGF = nullptr); // Emit code for the OpenACC Declare declaration. - void EmitOpenACCDeclare(const OpenACCDeclareDecl *D, CodeGenFunction *CGF); + void EmitOpenACCDeclare(const OpenACCDeclareDecl *D, + CodeGenFunction *CGF = nullptr); // Emit code for the OpenACC Routine declaration. - void EmitOpenACCRoutine(const OpenACCRoutineDecl *D, CodeGenFunction *CGF); + void EmitOpenACCRoutine(const OpenACCRoutineDecl *D, + CodeGenFunction *CGF = nullptr); /// Emit a code for requires directive. /// \param D Requires declaration |