[PATCH] Stop crashing on empty asm input constraints
Justin Bogner
mail at justinbogner.com
Sun Dec 15 17:04:57 PST 2013
"Duncan P. N. Exon Smith" <dexonsmith at apple.com> writes:
> commit ce572730bb2b1008443667a4d409810c2cab82ea
> Author: Duncan P. N. Exon Smith <dexonsmith at apple.com>
> Date: Thu Dec 12 19:07:57 2013 -0800
>
> Stop crashing on empty asm input constraints
>
> An empty string for an ASM input constraint is invalid, and will crash
> during clang CodeGen. Change TargetInfo::validateInputConstraint to
> reject an empty string.
>
> <rdar://problem/15552191>
>
> diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp
> index 5aa84af..d0ed6e6 100644
> --- a/lib/Basic/TargetInfo.cpp
> +++ b/lib/Basic/TargetInfo.cpp
> @@ -482,6 +482,9 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,
> ConstraintInfo &Info) const {
> const char *Name = Info.ConstraintStr.c_str();
>
> + if (!*Name)
> + return false;
> +
I think (*Name == '\0') makes the intention clearer here. From a
rudimentary grep the two styles are pretty much 50/50 in LLVM, so YMMV.
In any case, this is obviously correct. LGTM.
> while (*Name) {
> switch (*Name) {
> default:
> diff --git a/test/Sema/asm.c b/test/Sema/asm.c
> index c81f16a..1559b22 100644
> --- a/test/Sema/asm.c
> +++ b/test/Sema/asm.c
> @@ -13,6 +13,9 @@ void f() {
> asm ("foo\n" : "=a" (i) : "[" (i)); // expected-error {{invalid input constraint '[' in asm}}
> asm ("foo\n" : "=a" (i) : "[foo" (i)); // expected-error {{invalid input constraint '[foo' in asm}}
> asm ("foo\n" : "=a" (i) : "[symbolic_name]" (i)); // expected-error {{invalid input constraint '[symbolic_name]' in asm}}
> +
> + asm ("foo\n" : : "" (i)); // expected-error {{invalid input constraint '' in asm}}
> + asm ("foo\n" : "=a" (i) : "" (i)); // expected-error {{invalid input constraint '' in asm}}
> }
>
> void clobbers() {
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list