aboutsummaryrefslogtreecommitdiff
path: root/lib/Lex/Pragma.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-01 06:49:39 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-01 06:49:39 +0000
commit10285d9113c14d1e523f86a55b193eb752638ea5 (patch)
treedba2f12b27186e0dc354f00ddec4e8cacdd1497b /lib/Lex/Pragma.cpp
parent701e3366828adf740734ae5bf4424ecac059bc9a (diff)
Revert r151800, which was committed without review and has correctness issues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151804 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Lex/Pragma.cpp')
-rw-r--r--lib/Lex/Pragma.cpp105
1 files changed, 0 insertions, 105 deletions
diff --git a/lib/Lex/Pragma.cpp b/lib/Lex/Pragma.cpp
index 7a6ab7dd72..503fffe53d 100644
--- a/lib/Lex/Pragma.cpp
+++ b/lib/Lex/Pragma.cpp
@@ -663,101 +663,6 @@ void Preprocessor::HandlePragmaPopMacro(Token &PopMacroTok) {
}
}
-void Preprocessor::HandlePragmaIncludeAlias(Token& Tok) {
- // We will either get a quoted filename or a bracketed filename, and we
- // have to track which we got. The first filename is the source name,
- // and the second name is the mapped filename. If the first is quoted,
- // the second must be as well (cannot mix and match quotes and brackets).
- SourceLocation Loc = Tok.getLocation();
-
- // Get the open paren
- Lex(Tok);
- if (Tok.isNot(tok::l_paren)) {
- Diag(Tok, diag::warn_pragma_include_alias_expected) << "(";
- return;
- }
-
- // We expect either a quoted string literal, or a bracketed name
- Token SourceFilenameTok;
- CurPPLexer->LexIncludeFilename(SourceFilenameTok);
- if (SourceFilenameTok.is(tok::eod)) {
- // The diagnostic has already been handled
- return;
- }
-
- StringRef SourceFileName;
- SmallString<128> FileNameBuffer;
- if (SourceFilenameTok.is(tok::string_literal) ||
- SourceFilenameTok.is(tok::angle_string_literal)) {
- SourceFileName = getSpelling(SourceFilenameTok, FileNameBuffer);
- } else if (SourceFilenameTok.is(tok::less)) {
- // This could be a path instead of just a name
- FileNameBuffer.push_back('<');
- SourceLocation End;
- if (ConcatenateIncludeName(FileNameBuffer, End))
- return; // Diagnostic already emitted
- SourceFileName = FileNameBuffer.str();
- } else {
- Diag(Tok, diag::warn_pragma_include_alias_expected) << "include filename";
- return;
- }
- FileNameBuffer.clear();
-
- // Now we expect a comma, followed by another include name
- Lex(Tok);
- if (Tok.isNot(tok::comma)) {
- Diag(Tok, diag::warn_pragma_include_alias_expected) << ",";
- return;
- }
-
- Token ReplaceFilenameTok;
- CurPPLexer->LexIncludeFilename(ReplaceFilenameTok);
- if (ReplaceFilenameTok.is(tok::eod)) {
- // The diagnostic has already been handled
- return;
- }
-
- StringRef ReplaceFileName;
- if (ReplaceFilenameTok.is(tok::string_literal) ||
- ReplaceFilenameTok.is(tok::angle_string_literal)) {
- ReplaceFileName = getSpelling(ReplaceFilenameTok, FileNameBuffer);
- } else if (ReplaceFilenameTok.is(tok::less)) {
- // This could be a path instead of just a name
- FileNameBuffer.push_back('<');
- SourceLocation End;
- if (ConcatenateIncludeName(FileNameBuffer, End))
- return; // Diagnostic already emitted
- ReplaceFileName = FileNameBuffer.str();
- } else {
- Diag(Tok, diag::warn_pragma_include_alias_expected) << "include filename";
- return;
- }
-
- // Finally, we expect the closing paren
- Lex(Tok);
- if (Tok.isNot(tok::r_paren)) {
- Diag(Tok, diag::warn_pragma_include_alias_expected) << ")";
- return;
- }
-
- // Now that we have the source and target filenames, we need to make sure
- // they're both of the same type (angled vs non-angled)
- bool SourceIsAngled =
- GetIncludeFilenameSpelling(SourceFilenameTok.getLocation(),
- SourceFileName);
- bool ReplaceIsAngled =
- GetIncludeFilenameSpelling(ReplaceFilenameTok.getLocation(),
- ReplaceFileName);
- if (SourceIsAngled != ReplaceIsAngled) {
- Diag(Loc, diag::warn_pragma_include_alias_mismatch);
- return;
- }
-
- // Now we can let the include handler know about this mapping
- getHeaderSearchInfo().AddHeaderMapping(SourceFileName, ReplaceFileName,
- SourceIsAngled);
-}
-
/// AddPragmaHandler - Add the specified pragma handler to the preprocessor.
/// If 'Namespace' is non-null, then it is a token required to exist on the
/// pragma line before the pragma string starts, e.g. "STDC" or "GCC".
@@ -1038,15 +943,6 @@ struct PragmaCommentHandler : public PragmaHandler {
}
};
-/// PragmaIncludeAliasHandler - "#pragma include_alias("...")".
-struct PragmaIncludeAliasHandler : public PragmaHandler {
- PragmaIncludeAliasHandler() : PragmaHandler("include_alias") {}
- virtual void HandlePragma(Preprocessor &PP, PragmaIntroducerKind Introducer,
- Token &IncludeAliasTok) {
- PP.HandlePragmaIncludeAlias(IncludeAliasTok);
- }
-};
-
/// PragmaMessageHandler - "#pragma message("...")".
struct PragmaMessageHandler : public PragmaHandler {
PragmaMessageHandler() : PragmaHandler("message") {}
@@ -1199,6 +1095,5 @@ void Preprocessor::RegisterBuiltinPragmas() {
// MS extensions.
if (Features.MicrosoftExt) {
AddPragmaHandler(new PragmaCommentHandler());
- AddPragmaHandler(new PragmaIncludeAliasHandler());
}
}