Index: clang/include/clang/Lex/Preprocessor.h =================================================================== --- clang/include/clang/Lex/Preprocessor.h +++ clang/include/clang/Lex/Preprocessor.h @@ -150,7 +150,7 @@ llvm::BumpPtrAllocator BP; /// Identifiers for builtin macros and other builtins. - IdentifierInfo *Ident__LINE__, *Ident__FILE__; // __LINE__, __FILE__ + IdentifierInfo *Ident__LINE__, *Ident__FILE__, *Ident__FUNCTION__; // __LINE__, __FILE__, __FUNCTION__ IdentifierInfo *Ident__DATE__, *Ident__TIME__; // __DATE__, __TIME__ IdentifierInfo *Ident__INCLUDE_LEVEL__; // __INCLUDE_LEVEL__ IdentifierInfo *Ident__BASE_FILE__; // __BASE_FILE__ Index: clang/lib/Lex/PPMacroExpansion.cpp =================================================================== --- clang/lib/Lex/PPMacroExpansion.cpp +++ clang/lib/Lex/PPMacroExpansion.cpp @@ -337,6 +337,11 @@ /// RegisterBuiltinMacros - Register builtin macros, such as __LINE__ with the /// identifier table. void Preprocessor::RegisterBuiltinMacros() { +#ifdef _WIN32 + Ident__FUNCTION__ = RegisterBuiltinMacro(*this, "__FUNCTION__"); +#else + Ident__FUNCTION__ = Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__"); +#endif Ident__LINE__ = RegisterBuiltinMacro(*this, "__LINE__"); Ident__FILE__ = RegisterBuiltinMacro(*this, "__FILE__"); Ident__DATE__ = RegisterBuiltinMacro(*this, "__DATE__"); @@ -1561,6 +1566,13 @@ FN += PLoc.getFilename(); } else { FN += PLoc.getFilename(); +#ifdef _WIN32 + if (II == Ident__FUNCTION__) { + FN += "("; + FN += Twine(PLoc.getLine()).str(); + FN += ") "; + } +#endif } processPathForFileMacro(FN, getLangOpts(), getTargetInfo()); Lexer::Stringify(FN);