summaryrefslogtreecommitdiffstats
path: root/clang/Lex
diff options
context:
space:
mode:
Diffstat (limited to 'clang/Lex')
-rw-r--r--clang/Lex/Lexer.cpp9
-rw-r--r--clang/Lex/MacroExpander.cpp5
-rw-r--r--clang/Lex/Pragma.cpp3
-rw-r--r--clang/Lex/Preprocessor.cpp4
4 files changed, 12 insertions, 9 deletions
diff --git a/clang/Lex/Lexer.cpp b/clang/Lex/Lexer.cpp
index c686d918262..4bceedd4124 100644
--- a/clang/Lex/Lexer.cpp
+++ b/clang/Lex/Lexer.cpp
@@ -444,7 +444,7 @@ void Lexer::LexNumericConstant(LexerToken &Result, const char *CurPtr) {
/// LexStringLiteral - Lex the remainder of a string literal, after having lexed
/// either " or L".
-void Lexer::LexStringLiteral(LexerToken &Result, const char *CurPtr) {
+void Lexer::LexStringLiteral(LexerToken &Result, const char *CurPtr, bool Wide){
const char *NulCharacter = 0; // Does this string contain the \0 character?
char C = getAndAdvanceChar(CurPtr, Result);
@@ -468,7 +468,7 @@ void Lexer::LexStringLiteral(LexerToken &Result, const char *CurPtr) {
// If a nul character existed in the string, warn about it.
if (NulCharacter) Diag(NulCharacter, diag::null_in_string);
- Result.SetKind(tok::string_literal);
+ Result.SetKind(Wide ? tok::wide_string_literal : tok::string_literal);
// Update the location of the token as well as the BufferPtr instance var.
FormTokenWithChars(Result, CurPtr);
@@ -1104,7 +1104,8 @@ LexNextToken:
// Wide string literal.
if (Char == '"')
- return LexStringLiteral(Result, ConsumeChar(CurPtr, SizeTmp, Result));
+ return LexStringLiteral(Result, ConsumeChar(CurPtr, SizeTmp, Result),
+ true);
// Wide character constant.
if (Char == '\'')
@@ -1143,7 +1144,7 @@ LexNextToken:
case '"':
// Notify MIOpt that we read a non-whitespace/non-comment token.
MIOpt.ReadToken();
- return LexStringLiteral(Result, CurPtr);
+ return LexStringLiteral(Result, CurPtr, false);
// C99 6.4.6: Punctuators.
case '?':
diff --git a/clang/Lex/MacroExpander.cpp b/clang/Lex/MacroExpander.cpp
index 423eb9ba360..1a64e36a10d 100644
--- a/clang/Lex/MacroExpander.cpp
+++ b/clang/Lex/MacroExpander.cpp
@@ -161,8 +161,9 @@ static LexerToken StringifyArgument(const LexerToken *ArgToks,
// If this is a string or character constant, escape the token as specified
// by 6.10.3.2p2.
- if (Tok.getKind() == tok::string_literal || // "foo" and L"foo".
- Tok.getKind() == tok::char_constant) { // 'x' and L'x'.
+ if (Tok.getKind() == tok::string_literal || // "foo"
+ Tok.getKind() == tok::wide_string_literal || // L"foo"
+ Tok.getKind() == tok::char_constant) { // 'x' and L'x'.
Result += Lexer::Stringify(PP.getSpelling(Tok));
} else {
// Otherwise, just append the token.
diff --git a/clang/Lex/Pragma.cpp b/clang/Lex/Pragma.cpp
index 64b04ccfc60..2fbf9cc6c09 100644
--- a/clang/Lex/Pragma.cpp
+++ b/clang/Lex/Pragma.cpp
@@ -96,7 +96,8 @@ void Preprocessor::Handle_Pragma(LexerToken &Tok) {
// Read the '"..."'.
Lex(Tok);
- if (Tok.getKind() != tok::string_literal)
+ if (Tok.getKind() != tok::string_literal &&
+ Tok.getKind() != tok::wide_string_literal)
return Diag(PragmaLoc, diag::err__Pragma_malformed);
// Remember the string.
diff --git a/clang/Lex/Preprocessor.cpp b/clang/Lex/Preprocessor.cpp
index 702af741369..d8d3c42536b 100644
--- a/clang/Lex/Preprocessor.cpp
+++ b/clang/Lex/Preprocessor.cpp
@@ -444,7 +444,6 @@ void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
/// tokens from it instead of the current buffer.
void Preprocessor::EnterMacro(LexerToken &Tok, MacroArgs *Args) {
IdentifierInfo *Identifier = Tok.getIdentifierInfo();
- MacroInfo &MI = *Identifier->getMacroInfo();
IncludeMacroStack.push_back(IncludeStackInfo(CurLexer, CurDirLookup,
CurMacroExpander));
CurLexer = 0;
@@ -1492,7 +1491,8 @@ void Preprocessor::HandleIdentSCCSDirective(LexerToken &Tok) {
Lex(StrTok);
// If the token kind isn't a string, it's a malformed directive.
- if (StrTok.getKind() != tok::string_literal)
+ if (StrTok.getKind() != tok::string_literal &&
+ StrTok.getKind() != tok::wide_string_literal)
return Diag(StrTok, diag::err_pp_malformed_ident);
// Verify that there is nothing after the string, other than EOM.
OpenPOWER on IntegriCloud