diff options
author | Chad Rosier <mcrosier@apple.com> | 2013-04-19 20:37:49 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2013-04-19 20:37:49 +0000 |
commit | 7f2ab897743a9d0fafeb7bb2d28d732ac46275bf (patch) | |
tree | 722b8c933fe5abb60d1eb05496e664f6734b3e03 /clang/lib/Sema/SemaStmtAsm.cpp | |
parent | 89e594d176d849cdf4f31a40c1a5fe6db90df551 (diff) | |
download | bcm5719-llvm-7f2ab897743a9d0fafeb7bb2d28d732ac46275bf.tar.gz bcm5719-llvm-7f2ab897743a9d0fafeb7bb2d28d732ac46275bf.zip |
[ms-inline asm] The parsing of C++ identifiers is a task of the front-end parser,
not the asm parser. As such, begin moving the parsing logic in that direction.
This patch is just a temporary hack until the real frontend parser can be hooked
up. Part of rdar://13663589
llvm-svn: 179882
Diffstat (limited to 'clang/lib/Sema/SemaStmtAsm.cpp')
-rw-r--r-- | clang/lib/Sema/SemaStmtAsm.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/clang/lib/Sema/SemaStmtAsm.cpp b/clang/lib/Sema/SemaStmtAsm.cpp index 2190fc40c3b..0ed0fd56f50 100644 --- a/clang/lib/Sema/SemaStmtAsm.cpp +++ b/clang/lib/Sema/SemaStmtAsm.cpp @@ -494,9 +494,40 @@ public: } +// FIXME: Temporary hack until the frontend parser is hooked up to parse +// variables. +static bool isIdentifierChar(char c) { + return isalnum(c) || c == '_' || c == '$' || c == '.' || c == '@'; +} + +static void lexIdentifier(const char *&CurPtr) { + while (isIdentifierChar(*CurPtr)) + ++CurPtr; +} + +static StringRef parseIdentifier(StringRef Identifier) { + const char *StartPtr = Identifier.data(), *EndPtr, *CurPtr; + EndPtr = StartPtr + Identifier.size(); + CurPtr = StartPtr; + while(CurPtr <= EndPtr) { + if (isIdentifierChar(*CurPtr)) + lexIdentifier(CurPtr); + else if (CurPtr[0] == ':' && CurPtr[1] == ':') + CurPtr += 2; + else + break; + } + return StringRef(StartPtr, CurPtr - StartPtr); +} + NamedDecl *Sema::LookupInlineAsmIdentifier(StringRef Name, SourceLocation Loc, unsigned &Length, unsigned &Size, unsigned &Type, bool &IsVarDecl) { + // FIXME: Temporary hack until the frontend parser is hooked up to parse + // variables. + StringRef ParsedName = parseIdentifier(Name); + assert (ParsedName == Name && "Identifier not parsed correctly!"); + Length = 1; Size = 0; Type = 0; |