本文整理汇总了C++中clang::Token::is方法的典型用法代码示例。如果您正苦于以下问题:C++ Token::is方法的具体用法?C++ Token::is怎么用?C++ Token::is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类clang::Token
的用法示例。
在下文中一共展示了Token::is方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getIntegerConstantForMacroToken
static Optional<std::pair<llvm::APSInt, Type>>
getIntegerConstantForMacroToken(ClangImporter::Implementation &impl,
DeclContext *DC,
const clang::Token &token) {
// Integer literal.
if (token.is(clang::tok::numeric_constant)) {
if (auto literal = parseNumericLiteral<clang::IntegerLiteral>(impl,token)) {
auto value = llvm::APSInt { literal->getValue(),
literal->getType()->isUnsignedIntegerType() };
auto type = impl.importType(literal->getType(),
ImportTypeKind::Value,
isInSystemModule(DC),
Bridgeability::None);
return {{ value, type }};
}
// Macro identifier.
} else if (token.is(clang::tok::identifier) &&
token.getIdentifierInfo()->hasMacroDefinition()) {
auto rawID = token.getIdentifierInfo();
auto definition = impl.getClangPreprocessor().getMacroDefinition(rawID);
if (!definition)
return None;
ClangNode macroNode;
const clang::MacroInfo *macroInfo;
if (definition.getModuleMacros().empty()) {
macroInfo = definition.getMacroInfo();
macroNode = macroInfo;
} else {
// Follow MacroDefinition::getMacroInfo in preferring the last ModuleMacro
// rather than the first.
const clang::ModuleMacro *moduleMacro =
definition.getModuleMacros().back();
macroInfo = moduleMacro->getMacroInfo();
macroNode = moduleMacro;
}
auto importedID = impl.getNameImporter().importMacroName(rawID, macroInfo);
(void)impl.importMacro(importedID, macroNode);
auto searcher = impl.ImportedMacroConstants.find(macroInfo);
if (searcher == impl.ImportedMacroConstants.end()) {
return None;
}
auto importedConstant = searcher->second;
if (!importedConstant.first.isInt()) {
return None;
}
return {{ importedConstant.first.getInt(), importedConstant.second }};
}
return None;
}
示例2: GetPragmaValueFromToken
bool PragmaRecorder::GetPragmaValueFromToken(const clang::Token &Token,
std::string &PragmaValue) {
// Same as the GetPragmaName()
if (Token.is(clang::tok::r_paren))
PragmaValue.clear();
else
return GetPragmaNameFromToken(Token, PragmaValue);
return true;
}
示例3: GetPragmaNameFromToken
bool PragmaRecorder::GetPragmaNameFromToken(const clang::Token &Token,
std::string &PragmaName) {
if (Token.isLiteral())
PragmaName.assign(Token.getLiteralData(), Token.getLength());
else if (Token.is(clang::tok::identifier))
PragmaName.assign(Token.getIdentifierInfo()->getNameStart(),
Token.getIdentifierInfo()->getLength());
else
return false;
return true;
}
示例4: getIntegerConstantForMacroToken
static Optional<std::pair<llvm::APSInt, Type>>
getIntegerConstantForMacroToken(ClangImporter::Implementation &impl,
DeclContext *DC,
const clang::Token &token) {
// Integer literal.
if (token.is(clang::tok::numeric_constant)) {
if (auto literal = parseNumericLiteral<clang::IntegerLiteral>(impl,token)) {
auto value = llvm::APSInt { literal->getValue(),
literal->getType()->isUnsignedIntegerType() };
auto type = impl.importType(literal->getType(),
ImportTypeKind::Value,
isInSystemModule(DC),
/*isFullyBridgeable*/false);
return {{ value, type }};
}
// Macro identifier.
} else if (token.is(clang::tok::identifier) &&
token.getIdentifierInfo()->hasMacroDefinition()) {
auto rawID = token.getIdentifierInfo();
auto macroInfo = impl.getClangPreprocessor().getMacroInfo(rawID);
auto importedID = impl.getNameImporter().importMacroName(rawID, macroInfo);
impl.importMacro(importedID, macroInfo);
auto searcher = impl.ImportedMacroConstants.find(macroInfo);
if (searcher == impl.ImportedMacroConstants.end()) {
return None;
}
auto importedConstant = searcher->second;
if (!importedConstant.first.isInt()) {
return None;
}
return {{ importedConstant.first.getInt(), importedConstant.second }};
}
return None;
}
示例5: isSignToken
static bool isSignToken(const clang::Token &tok) {
return tok.is(clang::tok::plus) || tok.is(clang::tok::minus) ||
tok.is(clang::tok::tilde);
}
示例6: isStringToken
static bool isStringToken(const clang::Token &tok) {
return tok.is(clang::tok::string_literal) ||
tok.is(clang::tok::utf8_string_literal);
}
示例7: isBinaryOperator
static bool isBinaryOperator(const clang::Token &tok) {
return tok.is(clang::tok::amp) ||
tok.is(clang::tok::pipe) ||
tok.is(clang::tok::ampamp) ||
tok.is(clang::tok::pipepipe);
}