[LLVMdev] #define LLVM_ASM_PREFIX_CHAR '\1' to make code more readable?

Chris Lattner clattner at apple.com
Thu Dec 17 13:35:52 PST 2009


On Dec 7, 2009, at 5:03 AM, Timo Juhani Lindfors wrote:

> Chris Lattner <clattner at apple.com> writes:
>> Changing this from being a magic number to a 'static const char' is
>> fine with me, please don't use a macro though.
> 
> I do not like macros either. However, how should I remove magic
> numbers from
> 
> | } else if (Name == "\1stat64" ||
> |            Name == "\1lstat64" ||
> |            Name == "\1statvfs64" ||
> |            Name == "\1__isoc99_sscanf") {
> 
> without using a macro? Something like
> 
> | } else if (Name[0] == llvm_asm_prefix && Name.slice(1, 0) == "stat64" ||
> |            Name[0] == llvm_asm_prefix && Name.slice(1, 0) == "lstat64" ||
> |            Name[0] == llvm_asm_prefix && Name.slice(1, 0) == "statvfs64" ||
> |            Name[0] == llvm_asm_prefix && Name.slice(1, 0) == "__isoc99_sscanf") {
> 
> does not look very nice.

How about doing something like this above that code?

// Strip off asm prefix if present.
if (!Name.empty() && Name[0] == llvm_asm_prefix)
  Name = Name.substr(1);

I don't know if the empty check is necessary in context.

> Thanks, with this description I was able to find
> 
> /* User label prefix in effect for this compilation.  */
> extern const char *user_label_prefix;
> 
> from llvm-gcc's output.h. Is llvm_asm_prefix still a good name for the
> "\1" prefix?

How about llvm_disable_asm_prefix ?

-Chris



More information about the llvm-dev mailing list