building clang with Visual Studio 2008. Problems/fixes

Hi folks:

I checked out the llvm and cfe trunks tonight and followed the instructions on the clang page to build it. However, the code (or the build instructions) as it stands now has two issues and I am not sure if my fixes can actually be submitted as patches in both cases. I am building on a Windows 7 64bit machine and using Visual Studio 2008 Professional SP1 and am current on all hotfixes and updates.

  1. TableGen generates junk for Enums. In the tblgen vcproj, ClangAttrEmitter.cpp has an issue in Visual Studio 2008. The EnumArgument class declares the type member to be of type StringRef and then proceeds to call 'OS << " " << type" which prints out junk characters in the generated files and breaks compile eventually. The StringRef class does not declare an ostream << operator and while it has a str() operator for c style casts, VS2008 doesn’t use it. Not sure if gcc is expected to use the c-style cast automatically. In any case, all the other Argument classes use std::string to declare the type member and there seems to be no real use of the type member having a StringRef type. All it is used for in EnumArgument is output via ostream. Changing EnumArgument::type ffrom StringRef to std::string fixes this problem for me.

  2. The Attr.h class declares overloaded new and delete operators with Alignment defaulted to 16. VS2008 does not allow default arguments in the delete operator (presumably using whatever was used in the new operator to enforce symmetry). Only if I remove the default value for the Alignment argument in the Attr::operator delete decl does the project build.

With the above two changes, I can get the clang project in the cmake generated LLVN.sln solution to build nicely on VS2008.

These two are relatively simple changes but I don’t have access to a Linux/gcc install to check the cross platform nature of the second fix. Just informing the list in case someone who actually knows the codebase wants to fix these issues in a better way. I am also not sure if there are some issues with cmake not adding the correct flags to allow the code as it stands to build on windows/VS2008.



Should be fixed in r111513+r111514. In the future, please attach a
patch (i.e. the output of "svn diff" or equivalent).