aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm/lib/AsmParser/LLLexer.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2018-07-30 16:33:32 +0000
committerDimitry Andric <dim@FreeBSD.org>2018-07-30 16:33:32 +0000
commit51315c45ff5643a27f9c84b816db54ee870ba29b (patch)
tree1d87443fa0e53d3e6b315ce25787e64be0906bf7 /contrib/llvm/lib/AsmParser/LLLexer.cpp
parent6dfd050075216be8538ae375a22d30db72916f7e (diff)
parenteb11fae6d08f479c0799db45860a98af528fa6e7 (diff)
Merge llvm trunk r338150, and resolve conflicts.
Notes
Notes: svn path=/projects/clang700-import/; revision=336916
Diffstat (limited to 'contrib/llvm/lib/AsmParser/LLLexer.cpp')
-rw-r--r--contrib/llvm/lib/AsmParser/LLLexer.cpp132
1 files changed, 105 insertions, 27 deletions
diff --git a/contrib/llvm/lib/AsmParser/LLLexer.cpp b/contrib/llvm/lib/AsmParser/LLLexer.cpp
index d8be4ad42ad5..da9855ff630b 100644
--- a/contrib/llvm/lib/AsmParser/LLLexer.cpp
+++ b/contrib/llvm/lib/AsmParser/LLLexer.cpp
@@ -157,9 +157,10 @@ static const char *isLabelTail(const char *CurPtr) {
// Lexer definition.
//===----------------------------------------------------------------------===//
-LLLexer::LLLexer(StringRef StartBuf, SourceMgr &sm, SMDiagnostic &Err,
+LLLexer::LLLexer(StringRef StartBuf, SourceMgr &SM, SMDiagnostic &Err,
LLVMContext &C)
- : CurBuf(StartBuf), ErrorInfo(Err), SM(sm), Context(C), APFloatVal(0.0) {
+ : CurBuf(StartBuf), ErrorInfo(Err), SM(SM), Context(C), APFloatVal(0.0),
+ IgnoreColonInIdentifiers(false) {
CurPtr = CurBuf.begin();
}
@@ -219,6 +220,10 @@ lltok::Kind LLLexer::LexToken() {
SkipLineComment();
continue;
case '!': return LexExclaim();
+ case '^':
+ return LexCaret();
+ case ':':
+ return lltok::colon;
case '#': return LexHash();
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
@@ -328,6 +333,22 @@ bool LLLexer::ReadVarName() {
return false;
}
+// Lex an ID: [0-9]+. On success, the ID is stored in UIntVal and Token is
+// returned, otherwise the Error token is returned.
+lltok::Kind LLLexer::LexUIntID(lltok::Kind Token) {
+ if (!isdigit(static_cast<unsigned char>(CurPtr[0])))
+ return lltok::Error;
+
+ for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
+ /*empty*/;
+
+ uint64_t Val = atoull(TokStart + 1, CurPtr);
+ if ((unsigned)Val != Val)
+ Error("invalid value number (too large)!");
+ UIntVal = unsigned(Val);
+ return Token;
+}
+
lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
// Handle StringConstant: \"[^\"]*\"
if (CurPtr[0] == '"') {
@@ -357,17 +378,7 @@ lltok::Kind LLLexer::LexVar(lltok::Kind Var, lltok::Kind VarID) {
return Var;
// Handle VarID: [0-9]+
- if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
- for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
- /*empty*/;
-
- uint64_t Val = atoull(TokStart+1, CurPtr);
- if ((unsigned)Val != Val)
- Error("invalid value number (too large)!");
- UIntVal = unsigned(Val);
- return VarID;
- }
- return lltok::Error;
+ return LexUIntID(VarID);
}
/// Lex all tokens that start with a % character.
@@ -420,22 +431,18 @@ lltok::Kind LLLexer::LexExclaim() {
return lltok::exclaim;
}
+/// Lex all tokens that start with a ^ character.
+/// SummaryID ::= ^[0-9]+
+lltok::Kind LLLexer::LexCaret() {
+ // Handle SummaryID: ^[0-9]+
+ return LexUIntID(lltok::SummaryID);
+}
+
/// Lex all tokens that start with a # character.
/// AttrGrpID ::= #[0-9]+
lltok::Kind LLLexer::LexHash() {
// Handle AttrGrpID: #[0-9]+
- if (isdigit(static_cast<unsigned char>(CurPtr[0]))) {
- for (++CurPtr; isdigit(static_cast<unsigned char>(CurPtr[0])); ++CurPtr)
- /*empty*/;
-
- uint64_t Val = atoull(TokStart+1, CurPtr);
- if ((unsigned)Val != Val)
- Error("invalid value number (too large)!");
- UIntVal = unsigned(Val);
- return lltok::AttrGrpID;
- }
-
- return lltok::Error;
+ return LexUIntID(lltok::AttrGrpID);
}
/// Lex a label, integer type, keyword, or hexadecimal integer constant.
@@ -457,8 +464,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KeywordEnd = CurPtr;
}
- // If we stopped due to a colon, this really is a label.
- if (*CurPtr == ':') {
+ // If we stopped due to a colon, unless we were directed to ignore it,
+ // this really is a label.
+ if (!IgnoreColonInIdentifiers && *CurPtr == ':') {
StrVal.assign(StartChar-1, CurPtr++);
return lltok::LabelStr;
}
@@ -648,7 +656,9 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(nonnull);
KEYWORD(noredzone);
KEYWORD(noreturn);
+ KEYWORD(nocf_check);
KEYWORD(nounwind);
+ KEYWORD(optforfuzzing);
KEYWORD(optnone);
KEYWORD(optsize);
KEYWORD(readnone);
@@ -663,6 +673,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(sspstrong);
KEYWORD(strictfp);
KEYWORD(safestack);
+ KEYWORD(shadowcallstack);
KEYWORD(sanitize_address);
KEYWORD(sanitize_hwaddress);
KEYWORD(sanitize_thread);
@@ -708,6 +719,73 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(catch);
KEYWORD(filter);
+ // Summary index keywords.
+ KEYWORD(path);
+ KEYWORD(hash);
+ KEYWORD(gv);
+ KEYWORD(guid);
+ KEYWORD(name);
+ KEYWORD(summaries);
+ KEYWORD(flags);
+ KEYWORD(linkage);
+ KEYWORD(notEligibleToImport);
+ KEYWORD(live);
+ KEYWORD(dsoLocal);
+ KEYWORD(function);
+ KEYWORD(insts);
+ KEYWORD(funcFlags);
+ KEYWORD(readNone);
+ KEYWORD(readOnly);
+ KEYWORD(noRecurse);
+ KEYWORD(returnDoesNotAlias);
+ KEYWORD(calls);
+ KEYWORD(callee);
+ KEYWORD(hotness);
+ KEYWORD(unknown);
+ KEYWORD(hot);
+ KEYWORD(critical);
+ KEYWORD(relbf);
+ KEYWORD(variable);
+ KEYWORD(aliasee);
+ KEYWORD(refs);
+ KEYWORD(typeIdInfo);
+ KEYWORD(typeTests);
+ KEYWORD(typeTestAssumeVCalls);
+ KEYWORD(typeCheckedLoadVCalls);
+ KEYWORD(typeTestAssumeConstVCalls);
+ KEYWORD(typeCheckedLoadConstVCalls);
+ KEYWORD(vFuncId);
+ KEYWORD(offset);
+ KEYWORD(args);
+ KEYWORD(typeid);
+ KEYWORD(summary);
+ KEYWORD(typeTestRes);
+ KEYWORD(kind);
+ KEYWORD(unsat);
+ KEYWORD(byteArray);
+ KEYWORD(inline);
+ KEYWORD(single);
+ KEYWORD(allOnes);
+ KEYWORD(sizeM1BitWidth);
+ KEYWORD(alignLog2);
+ KEYWORD(sizeM1);
+ KEYWORD(bitMask);
+ KEYWORD(inlineBits);
+ KEYWORD(wpdResolutions);
+ KEYWORD(wpdRes);
+ KEYWORD(indir);
+ KEYWORD(singleImpl);
+ KEYWORD(branchFunnel);
+ KEYWORD(singleImplName);
+ KEYWORD(resByArg);
+ KEYWORD(byArg);
+ KEYWORD(uniformRetVal);
+ KEYWORD(uniqueRetVal);
+ KEYWORD(virtualConstProp);
+ KEYWORD(info);
+ KEYWORD(byte);
+ KEYWORD(bit);
+
#undef KEYWORD
// Keywords for types.