|
@@ -363,7 +363,6 @@ void Preprocessor::RegisterBuiltinMacros() {
|
|
}
|
|
}
|
|
|
|
|
|
// Clang Extensions.
|
|
// Clang Extensions.
|
|
- Ident__FILE_NAME__ = RegisterBuiltinMacro(*this, "__FILE_NAME__");
|
|
|
|
Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
|
|
Ident__has_feature = RegisterBuiltinMacro(*this, "__has_feature");
|
|
Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
|
|
Ident__has_extension = RegisterBuiltinMacro(*this, "__has_extension");
|
|
Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
|
|
Ident__has_builtin = RegisterBuiltinMacro(*this, "__has_builtin");
|
|
@@ -1475,8 +1474,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
|
|
// __LINE__ expands to a simple numeric value.
|
|
// __LINE__ expands to a simple numeric value.
|
|
OS << (PLoc.isValid()? PLoc.getLine() : 1);
|
|
OS << (PLoc.isValid()? PLoc.getLine() : 1);
|
|
Tok.setKind(tok::numeric_constant);
|
|
Tok.setKind(tok::numeric_constant);
|
|
- } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__ ||
|
|
|
|
- II == Ident__FILE_NAME__) {
|
|
|
|
|
|
+ } else if (II == Ident__FILE__ || II == Ident__BASE_FILE__) {
|
|
// C99 6.10.8: "__FILE__: The presumed name of the current source file (a
|
|
// C99 6.10.8: "__FILE__: The presumed name of the current source file (a
|
|
// character string literal)". This can be affected by #line.
|
|
// character string literal)". This can be affected by #line.
|
|
PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
|
|
PresumedLoc PLoc = SourceMgr.getPresumedLoc(Tok.getLocation());
|
|
@@ -1497,27 +1495,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
|
|
// Escape this filename. Turn '\' -> '\\' '"' -> '\"'
|
|
// Escape this filename. Turn '\' -> '\\' '"' -> '\"'
|
|
SmallString<128> FN;
|
|
SmallString<128> FN;
|
|
if (PLoc.isValid()) {
|
|
if (PLoc.isValid()) {
|
|
- // __FILE_NAME__ is a Clang-specific extension that expands to the
|
|
|
|
- // the last part of __FILE__.
|
|
|
|
- if (II == Ident__FILE_NAME__) {
|
|
|
|
- // Try to get the last path component.
|
|
|
|
- StringRef PLFileName = PLoc.getFilename();
|
|
|
|
- size_t LastSep = PLFileName.find_last_of('/');
|
|
|
|
-#ifdef _WIN32
|
|
|
|
- // On Windows targets, absolute paths can be normalized to use
|
|
|
|
- // backslashes instead - handle this potential case here.
|
|
|
|
- if (LastSep == StringRef::npos)
|
|
|
|
- LastSep = PLFileName.find_last_of('\\');
|
|
|
|
-#endif
|
|
|
|
- // Skip the separator and get the last part, otherwise fall back on
|
|
|
|
- // returning the original full filename.
|
|
|
|
- if (LastSep != StringRef::npos)
|
|
|
|
- FN += PLFileName.substr(LastSep+1);
|
|
|
|
- else
|
|
|
|
- FN += PLFileName;
|
|
|
|
- } else {
|
|
|
|
- FN += PLoc.getFilename();
|
|
|
|
- }
|
|
|
|
|
|
+ FN += PLoc.getFilename();
|
|
Lexer::Stringify(FN);
|
|
Lexer::Stringify(FN);
|
|
OS << '"' << FN << '"';
|
|
OS << '"' << FN << '"';
|
|
}
|
|
}
|