In particular, #pragma clang __debug, and #include implicitly changed
into @import were causing assertion failures.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@200475
91177308-0d34-0410-b5e6-
96231b3b80d8
OS << "@import " << Imported->getFullModuleName() << ";"
<< " /* clang -E: implicit import for \"" << File->getName() << "\" */";
EmittedTokensOnThisLine = true;
+ setEmittedDirectiveOnThisLine();
}
}
// -traditional-cpp the lexer keeps /all/ whitespace, including comments.
SourceLocation StartLoc = Tok.getLocation();
Callbacks->MoveToLine(StartLoc.getLocWithOffset(Tok.getLength()));
- } else if (Tok.is(tok::annot_module_include) ||
- Tok.is(tok::annot_module_begin) ||
- Tok.is(tok::annot_module_end)) {
- // PrintPPOutputPPCallbacks::InclusionDirective handles producing
- // appropriate output here. Ignore this token entirely.
+ } else if (Tok.isAnnotation()) {
+ // PrintPPOutputPPCallbacks handles producing appropriate output here.
+ // Ignore this token entirely.
PP.Lex(Tok);
continue;
} else if (IdentifierInfo *II = Tok.getIdentifierInfo()) {
return false;
tok::TokenKind PrevKind = PrevTok.getKind();
- if (PrevTok.getIdentifierInfo()) // Language keyword or named operator.
- PrevKind = tok::identifier;
+ if (!PrevTok.isAnnotation() && PrevTok.getIdentifierInfo())
+ PrevKind = tok::identifier; // Language keyword or named operator.
// Look up information on when we should avoid concatenation with prevtok.
unsigned ConcatInfo = TokenInfo[PrevKind];
// In C++11, a string or character literal followed by an identifier is a
// single token.
- if (Tok.getIdentifierInfo())
+ if (!Tok.isAnnotation() && Tok.getIdentifierInfo())
return true;
// A ud-suffix is an identifier. If the previous token ends with one, treat
if (Tok.is(tok::numeric_constant))
return GetFirstChar(PP, Tok) != '.';
+ if (Tok.isAnnotation()) // token will be put on its own line.
+ return false;
+
if (Tok.getIdentifierInfo() || Tok.is(tok::wide_string_literal) ||
Tok.is(tok::utf8_string_literal) || Tok.is(tok::utf16_string_literal) ||
Tok.is(tok::utf32_string_literal) || Tok.is(tok::wide_char_constant) ||
--- /dev/null
+module a {
+ header "a.h"
+ export *
+}
--- /dev/null
+// RUN: %clang_cc1 -E %s -fmodules -fmodules-cache-path=%t -I%S/Inputs | FileCheck %s
+// CHECK: @import a; /* clang -E: implicit import
+#include "a.h"
+// CHECK: #pragma clang __debug parser_crash
+#pragma clang __debug parser_crash