forked from qt-creator/qt-creator
		
	C++: fix trigraph parsing in macros.
Trigraphs must only be parsed before/during preprocessing. The preprocessor will now replace trigraphs with their standard form, and re-lexing in TranslationUnit will not try to parse any trigraph. Also added a few missing trigraphs: ??=, ??', ??! and ??-. Task-number: QTCREATORBUG-13253 Change-Id: I1723ed53b00090b878c22b83b7e963b647b65f72 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
		| @@ -50,6 +50,7 @@ | ||||
| #include <cplusplus/Lexer.h> | ||||
| #include <cplusplus/Token.h> | ||||
| #include <cplusplus/Literals.h> | ||||
| #include <cplusplus/cppassert.h> | ||||
|  | ||||
| #include <utils/scopedswap.h> | ||||
|  | ||||
| @@ -1439,7 +1440,25 @@ void Preprocessor::preprocess(const QString &fileName, const QByteArray &source, | ||||
|         enforceSpacing(tk, macroExpanded); | ||||
|  | ||||
|         // Finally output the token. | ||||
|         currentOutputBuffer().append(tk.tokenStart(), tk.bytes()); | ||||
|         if (!tk.f.trigraph) { | ||||
|             currentOutputBuffer().append(tk.tokenStart(), tk.bytes()); | ||||
|         } else { | ||||
|             switch (tk.kind()) { | ||||
|             case T_LBRACKET:    currentOutputBuffer().append("["); break; | ||||
|             case T_RBRACKET:    currentOutputBuffer().append("]"); break; | ||||
|             case T_LBRACE:      currentOutputBuffer().append("{"); break; | ||||
|             case T_RBRACE:      currentOutputBuffer().append("}"); break; | ||||
|             case T_POUND:       currentOutputBuffer().append("#"); break; | ||||
|             case T_POUND_POUND: currentOutputBuffer().append("##"); break; | ||||
|             case T_CARET:       currentOutputBuffer().append("^"); break; | ||||
|             case T_CARET_EQUAL: currentOutputBuffer().append("^="); break; | ||||
|             case T_PIPE:        currentOutputBuffer().append("|"); break; | ||||
|             case T_PIPE_EQUAL:  currentOutputBuffer().append("|="); break; | ||||
|             case T_TILDE:       currentOutputBuffer().append("~"); break; | ||||
|             case T_TILDE_EQUAL: currentOutputBuffer().append("~="); break; | ||||
|             default: CPP_ASSERT(0, qDebug() << tk.spell()); break; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|     } while (tk.isNot(T_EOF_SYMBOL)); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user