=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
AaronBallman wrote:
> @AaronBallman, @c
apple-fcloutier wrote:
@AaronBallman, @cor3ntin, what do you think? Split this in two, [like Oliver
suggests](https://github.com/llvm/llvm-project/pull/135864#issuecomment-2879466843)?
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commits m
ojhunt wrote:
@apple-fcloutier I feel like this PR can be made easier to review by separating
the improvements to string constant evaluation from the improvements to the
format string checking, as the former introduces a number of new interfaces and
the operations required to provide those API
https://github.com/apple-fcloutier updated
https://github.com/llvm/llvm-project/pull/135864
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Aria
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(c
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(const Expr *E, ComplexValue
&Res, EvalInfo &Info);
static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result,
EvalInfo &Info);
static bool EvaluateAsRValue(EvalInfo &Info, const E
@@ -17971,46 +18006,117 @@ static bool EvaluateBuiltinStrLen(const Expr *E,
uint64_t &Result,
S->getCharByteWidth() == 1 &&
// FIXME: Add fast-path for wchar_t too.
Info.Ctx.hasSameUnqualifiedType(CharTy, Info.Ctx.CharTy)) {
- Str = Str.substr(Off)
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(c
@@ -791,10 +791,26 @@ class Expr : public ValueStmt {
const Expr *PtrExpression, ASTContext &Ctx,
EvalResult &Status) const;
- /// If the current Expr can be evaluated to a pointer to a null-terminated
- /// c
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier
Message-ID:
In-Reply-To:
@@ -791,10 +791,2
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(const Expr *E, ComplexValue
&Res, EvalInfo &Info);
static bool EvaluateAtomic(const Expr *E, const LValue *This, APValue &Result,
EvalInfo &Info);
static bool EvaluateAsRValue(EvalInfo &Info, const E
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -1920,9 +1920,17 @@ static bool EvaluateComplex(c
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -17971,46 +18006,117 @@ static bool EvaluateBuilt
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
github-actions[bot] wrote:
:warning: C/C++ code formatter, clang-format found issues in your c
https://github.com/apple-fcloutier updated
https://github.com/llvm/llvm-project/pull/135864
Rate limit · GitHub
body {
background-color: #f6f8fa;
color: #24292e;
font-family: -apple-system,BlinkMacSystemFont,Segoe
UI,Helvetica,Aria
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) {
}
#endif
+
+#if __cplus
apple-fcloutier wrote:
Yeah, I'm fixing the merge conflict, unfortunately I got sidetracked
_immediately_ after I pushed and found there was a conflict. I'll hopefully get
it out by EOD.
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commit
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) {
}
#endif
+
+#if __cplusplus >= 202000L
+class my_string {
+ char *data;
+ unsigned size;
+
+public:
+ template
+ constexpr my_string(const char (&literal)[N]) {
+data = new char[N+1];
+for (size = 0; size < N; +
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) {
}
#endif
+
+#if __cplusplus >= 202000L
+class my_string {
+ char *data;
+ unsigned size;
+
+public:
+ template
+ constexpr my_string(const char (&literal)[N]) {
+data = new char[N+1];
+for (size = 0; size < N; +
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
ojhunt wrote:
The pointer auth options PR would also benefit from this - it currently has an
ad hoc and restricted version of this as it needed to support
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -1,6 +1,14 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -Wformat-non-iso
-Wformat-pedantic -fblocks %s
// RUN: %clang_cc1 -fsyntax-only -verify
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -9105,7 +9105,7 @@ def err_expected_callable_argument : Error<
def note_building_builtin_dump_struct_call : Note<
"in call to printing function with arguments '(
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) {
}
#endif
+
+#if __cplusplus >= 202000L
+class my_string {
+ char *data;
+ unsigned size;
+
+public:
+ templ
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
https://github.com/hubert-reinterpretcast edited
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.l
=?utf-8?q?F=C3=A9lix?= Cloutier ,
=?utf-8?q?F=C3=A9lix?= Cloutier
Message-ID:
In-Reply-To:
@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
"using '%0' format specifier, but argument has boolean value">,
InGroup;
def note_format_string_defined : Note<
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
apple-fcloutier wrote:
(The broken tests are because I updated the note wording and then did not
update the tests. We have ongoing conversation for that so I'll fix that when
we have a resolution)
https://githu
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
"using '%0' format specifier, but argument has boolean value">,
InGroup;
def note_format_string_defined : Note<"format st
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
apple-fcloutier wrote:
I have addressed current feedback, except that I still haven't checked for perf
(will follow Aaron's directions on that soon) and I'm still working out what I
need to check for `if constex
=?utf-8?q?Félix?= Cloutier ,
=?utf-8?q?Félix?= Cloutier
Message-ID:
In-Reply-To:
https://github.com/apple-fcloutier updated
https://github.com/llvm/llvm-project/pull/135864
>From 7e15ec24e6de96b9828f13f21099446e55831591 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?F=C3=A9lix=20Cloutier?=
Date: T
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
"using '%0' format specifier, but argument has boolean value">,
InGroup;
def note_format_string_defined : Note<"format string is defined here">;
+def note_format_string_evaluated_to : Note<
+ "format stri
@@ -17945,15 +17945,36 @@ bool Expr::tryEvaluateObjectSize(uint64_t &Result,
ASTContext &Ctx,
static bool EvaluateBuiltinStrLen(const Expr *E, uint64_t &Result,
EvalInfo &Info, std::string *StringResult) {
- if (!E->getType()->hasPointerRepr
@@ -265,6 +265,9 @@ related warnings within the method body.
``format_matches`` accepts an example valid format string as its third
argument. For more information, see the Clang attributes documentation.
+- Format string checking now supports the compile-time evaluation of
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-linux-android %s
+// expected-n
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-linux-android %s
+// expected-n
https://github.com/apple-fcloutier edited
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -5935,8 +5936,14 @@ static void CheckFormatString(
llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
bool IgnoreStringsWithoutSpecifiers);
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-linux-android %s
+// expected-n
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -6331,26 +6321,79 @@ static StringLiteralCheckType checkFormatStringExpr(
}
}
-return SLCT_NotALiteral;
+// try to constant-evaluate the string
+break;
}
default:
+// try to constant-evaluate the string
+break;
+ }
+
+ const StringLit
@@ -5935,8 +5936,14 @@ static void CheckFormatString(
llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
bool IgnoreStringsWithoutSpecifiers);
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-
@@ -5935,8 +5936,14 @@ static void CheckFormatString(
llvm::SmallBitVector &CheckedVarArgs, UncoveredArgHandler &UncoveredArg,
bool IgnoreStringsWithoutSpecifiers);
-static const Expr *maybeConstEvalStringLiteral(ASTContext &Context,
-
@@ -17945,15 +17945,36 @@ bool Expr::tryEvaluateObjectSize(uint64_t &Result,
ASTContext &Ctx,
static bool EvaluateBuiltinStrLen(const Expr *E, uint64_t &Result,
cor3ntin wrote:
We probably want to rename that method to `EvaluateCString` or something like
tha
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-linux-android %s
+// expected-n
https://github.com/hubert-reinterpretcast edited
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -238,3 +246,69 @@ void f(Scoped1 S1, Scoped2 S2) {
}
#endif
+
+#if __cplusplus >= 202000L
+class my_string {
+ char *data;
+ unsigned size;
+
+public:
+ template
+ constexpr my_string(const char (&literal)[N]) {
+data = new char[N+1];
+for (size = 0; size < N; +
@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
"using '%0' format specifier, but argument has boolean value">,
InGroup;
def note_format_string_defined : Note<"format string is defined here">;
+def note_format_string_evaluated_to : Note<
+ "format stri
@@ -10170,6 +10170,8 @@ def warn_format_bool_as_character : Warning<
"using '%0' format specifier, but argument has boolean value">,
InGroup;
def note_format_string_defined : Note<"format string is defined here">;
+def note_format_string_evaluated_to : Note<
+ "format stri
https://github.com/apple-fcloutier edited
https://github.com/llvm/llvm-project/pull/135864
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
@@ -3,6 +3,11 @@
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-unknown-fuchsia %s
// RUN: %clang_cc1 -fblocks -fsyntax-only -verify -Wformat-nonliteral -isystem
%S/Inputs -triple=x86_64-linux-android %s
+// expected-n
llvmbot wrote:
@llvm/pr-subscribers-clang
Author: None (apple-fcloutier)
Changes
I [asked on the
forums](https://discourse.llvm.org/t/should-attribute-format-checking-try-to-const-evaluate-strings/85854/4)
and people were generally supportive of the idea, so:
Clang's -Wformat checker ca
54 matches
Mail list logo