#include "clang/Basic/PragmaKinds.h"
#include "clang/Basic/TargetInfo.h"
#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/Token.h"
#include "clang/Parse/LoopHint.h"
#include "clang/Parse/ParseDiagnostic.h"
#include "clang/Parse/Parser.h"
#include "clang/Parse/RAIIObjectsForParser.h"
#include "clang/Sema/Scope.h"
+#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
Token &FirstToken) override;
};
+void markAsReinjectedForRelexing(llvm::MutableArrayRef<clang::Token> Toks) {
+ for (auto &T : Toks)
+ T.setFlag(clang::Token::IsReinjected);
+}
} // end namespace
void Parser::initializePragmaHandlers() {
TokenVector.push_back(EoF);
// We must allocate this array with new because EnterTokenStream is going to
// delete it later.
+ markAsReinjectedForRelexing(TokenVector);
auto TokenArray = std::make_unique<Token[]>(TokenVector.size());
std::copy(TokenVector.begin(), TokenVector.end(), TokenArray.get());
auto Value = new (PP.getPreprocessorAllocator())
EOFTok.setLocation(Tok.getLocation());
ValueList.push_back(EOFTok); // Terminates expression for parsing.
+ markAsReinjectedForRelexing(ValueList);
Info.Toks = llvm::makeArrayRef(ValueList).copy(PP.getPreprocessorAllocator());
Info.PragmaName = PragmaName;
EOFTok.setLocation(EndLoc);
AttributeTokens.push_back(EOFTok);
+ markAsReinjectedForRelexing(AttributeTokens);
Info->Tokens =
llvm::makeArrayRef(AttributeTokens).copy(PP.getPreprocessorAllocator());
}