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

Timo Juhani Lindfors timo.lindfors at iki.fi
Mon Dec 7 05:03:38 PST 2009


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.

>  The declaration of this should go in Mangler.h

Ok.

> \01 means 'do not add the "USER LABEL PREFIX" for the target', names
> definitely do need to be mangled for some targets even without this.
> For example, elf systems can't handle symbols with spaces in them.

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?




More information about the llvm-dev mailing list