[clang] [clang] Add per-global code model attribute (PR #72078)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 12 18:51:08 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 18415c8365047841c4671798e0129ca9bbd03c40 29c89161a55c2d7355a0d0b544044ea72348c086 -- clang/test/Sema/attr-model.c clang/lib/CodeGen/CodeGenModule.cpp clang/lib/Sema/SemaDeclAttr.cpp clang/test/CodeGen/attributes.c
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index f783130e3c..f7347ab912 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -4778,11 +4778,11 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName, llvm::Type *Ty,
if (D->hasAttr<CodeModelAttr>()) {
if (const CodeModelAttr *CMA = D->getAttr<CodeModelAttr>()) {
auto CM = llvm::StringSwitch<llvm::CodeModel::Model>(CMA->getModel())
- .Case("tiny", llvm::CodeModel::Tiny)
- .Case("kernel", llvm::CodeModel::Kernel)
- .Case("medium", llvm::CodeModel::Medium)
- .Case("large", llvm::CodeModel::Large)
- .Default(llvm::CodeModel::Small);
+ .Case("tiny", llvm::CodeModel::Tiny)
+ .Case("kernel", llvm::CodeModel::Kernel)
+ .Case("medium", llvm::CodeModel::Medium)
+ .Case("large", llvm::CodeModel::Large)
+ .Default(llvm::CodeModel::Small);
GV->setCodeModel(CM);
}
}
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 8646c49460..3cf50284bb 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3377,8 +3377,8 @@ static void handleCodeModelAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
return;
// Check that the value.
- if (Model != "tiny" && Model != "small"
- && Model != "kernel" && Model != "medium" && Model != "large") {
+ if (Model != "tiny" && Model != "small" && Model != "kernel" &&
+ Model != "medium" && Model != "large") {
S.Diag(LiteralLoc, diag::err_attr_codemodel_arg);
return;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/72078
More information about the cfe-commits
mailing list