<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Yes, well that is a good point w.r.t. strings as typically passed to string.h functions. I guess in this case I had figured that the use of __FILE__ could easily be optimized since it becomes a string constant. Am I wrong? Is the issue that __FILE__ might occur multiple times in a source file and thus become a merged constant? Perhaps there is simply not much use for a string-optimizing feature since reducing program size isn’t a goal for most developers these days?</div><div><br></div><div>Then, more to the point, I wonder if there shouldn’t be a macro in clang/llvm for returning only the current source file name, e.g. __FILE_NAME__. I don’t know what the feeling is on introducing macros that do not exist in gcc, since it seems that up until now the approach has been quite conservative. Does no one else have a desire to easily suppress the full hard drive paths that will show up in their binaries with the use of __FILE__? Or perhaps everyone simply has their own existing solutions to this, such as a build system that can pass clang the files by relative path, or placing the source code on its own volume?</div><div><br></div><br><div><div>On Sep 20, 2014, at 10:41 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr">I imagine that would be difficult. If you pass the resulting pointer out to unknown code/functions, there's nothing to stop that code from walking backwards from the pointer and having well defined behavior of observing the prefix you tried to hide.</p><p dir="ltr">Essentially the compiler would have to be able to see and analyze all uses of that pointer in one go before it could optimize away the prefix.</p>
<div class="gmail_quote">On Sep 19, 2014 8:41 PM, "Iritscen" <<a href="mailto:iritscen@yahoo.com">iritscen@yahoo.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all. Is there a way to get llvm/clang at build-time to optimize a string.h call so that the final form of the string is saved in the binary? For instance, for a statement like...<br>
<br>
strrchr(__FILE__, '/') + 1<br>
<br>
…and where clang is called on this code’s source file with “clang /some/long/path/file.c”, can I end up with only “file.c” stored in the binary on disk? I think you can see that I am attempting to avoid full paths from my machine ending up in the program. My IDE, Xcode, always passes full paths to clang when building. Thanks.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu/" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div>
</blockquote></div><br></body></html>