[clang] Adding diagnostics for unsupported option (PR #125643)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 4 08:09:55 PST 2025
https://github.com/ShashwathiNavada updated https://github.com/llvm/llvm-project/pull/125643
>From 0aebcd7119fbcd51154c5d9706752e8ff3f041bc Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 4 Feb 2025 00:16:09 -0600
Subject: [PATCH 1/5] Adding diagnostics for unsupported option
---
clang/lib/Frontend/CompilerInvocation.cpp | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 11fd6ab7f52a79..ac8d8be572012b 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1897,6 +1897,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
Opts.setInlining(CodeGenOptions::NormalInlining);
}
+// -mcmodel option.
+if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ))
+{
+ llvm::StringRef modelName = A->getValue();
+ if(modelName=="tiny" && !T.isARM())
+ Diags.Report(diag::err_drv_unsupported_option_argument_for_target)
+ << A->getSpelling() <<modelName<< T.getTriple();
+}
+
// PIC defaults to -fno-direct-access-external-data while non-PIC defaults to
// -fdirect-access-external-data.
Opts.DirectAccessExternalData =
>From f791b1d8e6006f0e5b616e5dd786c84ad34b29f3 Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 4 Feb 2025 00:36:37 -0600
Subject: [PATCH 2/5] minor changes
---
clang/lib/Frontend/CompilerInvocation.cpp | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index ac8d8be572012b..1242073ea67461 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1897,14 +1897,13 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
Opts.setInlining(CodeGenOptions::NormalInlining);
}
-// -mcmodel option.
-if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ))
-{
+ // -mcmodel option.
+ if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)){
llvm::StringRef modelName = A->getValue();
if(modelName=="tiny" && !T.isARM())
- Diags.Report(diag::err_drv_unsupported_option_argument_for_target)
- << A->getSpelling() <<modelName<< T.getTriple();
-}
+ Diags.Report(diag::err_drv_unsupported_option_argument_for_target)
+ << A->getSpelling() << modelName << T.getTriple();
+ }
// PIC defaults to -fno-direct-access-external-data while non-PIC defaults to
// -fdirect-access-external-data.
>From 689dc3a3472ff8270ee9631b235e776f5fa1a27f Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 4 Feb 2025 00:49:37 -0600
Subject: [PATCH 3/5] minor changes
---
clang/lib/Frontend/CompilerInvocation.cpp | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 1242073ea67461..15d382620d2792 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1896,13 +1896,15 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
} else {
Opts.setInlining(CodeGenOptions::NormalInlining);
}
-
- // -mcmodel option.
- if (const llvm::opt::Arg *A = Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)){
+
+ // -mcmodel option.
+ if (const llvm::opt::Arg *A =
+ Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) {
llvm::StringRef modelName = A->getValue();
- if(modelName=="tiny" && !T.isARM())
+ if (modelName == "tiny" && !T.isARM()) {
Diags.Report(diag::err_drv_unsupported_option_argument_for_target)
- << A->getSpelling() << modelName << T.getTriple();
+ << A->getSpelling() << modelName << T.getTriple();
+ }
}
// PIC defaults to -fno-direct-access-external-data while non-PIC defaults to
>From 28fcb0ee20645cd1d30dd15bfd7f6eff402ba2b9 Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 4 Feb 2025 01:01:00 -0600
Subject: [PATCH 4/5] minor changes
---
clang/lib/Frontend/CompilerInvocation.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index 15d382620d2792..f858ec2234cb5d 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1896,7 +1896,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
} else {
Opts.setInlining(CodeGenOptions::NormalInlining);
}
-
+
// -mcmodel option.
if (const llvm::opt::Arg *A =
Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) {
>From 843d4ccf4c41a78397e14eb5d9459a4921325741 Mon Sep 17 00:00:00 2001
From: ShashwathiNavada <shashwathinavada at gmail.com>
Date: Tue, 4 Feb 2025 21:39:44 +0530
Subject: [PATCH 5/5] Addressed build fail
---
clang/lib/Frontend/CompilerInvocation.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index f858ec2234cb5d..48f66931af06ce 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1901,7 +1901,7 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
if (const llvm::opt::Arg *A =
Args.getLastArg(clang::driver::options::OPT_mcmodel_EQ)) {
llvm::StringRef modelName = A->getValue();
- if (modelName == "tiny" && !T.isARM()) {
+ if (modelName == "tiny" && !(T.isARM() || T.isAArch64())) {
Diags.Report(diag::err_drv_unsupported_option_argument_for_target)
<< A->getSpelling() << modelName << T.getTriple();
}
More information about the cfe-commits
mailing list