diff options
author | Daniel Jasper <djasper@google.com> | 2012-12-20 20:25:19 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2012-12-20 20:25:19 +0000 |
commit | d1122cb50de7d7638f414759ecb65cf234c07ab0 (patch) | |
tree | 21e39b52954346614a1982886e215ea024a20bf9 /clang/lib/Parse/ParseExpr.cpp | |
parent | 2ababf68d78be7b4dcd76a04f1becfd92b791e66 (diff) | |
download | bcm5719-llvm-d1122cb50de7d7638f414759ecb65cf234c07ab0.tar.gz bcm5719-llvm-d1122cb50de7d7638f414759ecb65cf234c07ab0.zip |
Move operator precedence calculation to new header
Thereby, it can be reused by clang-format and others.
Review: http://llvm-reviews.chandlerc.com/D229
llvm-svn: 170757
Diffstat (limited to 'clang/lib/Parse/ParseExpr.cpp')
-rw-r--r-- | clang/lib/Parse/ParseExpr.cpp | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp index b7705f8c0d3..52293369290 100644 --- a/clang/lib/Parse/ParseExpr.cpp +++ b/clang/lib/Parse/ParseExpr.cpp @@ -32,67 +32,6 @@ #include "llvm/ADT/SmallVector.h" using namespace clang; -/// \brief Return the precedence of the specified binary operator token. -static prec::Level getBinOpPrecedence(tok::TokenKind Kind, - bool GreaterThanIsOperator, - bool CPlusPlus0x) { - switch (Kind) { - case tok::greater: - // C++ [temp.names]p3: - // [...] When parsing a template-argument-list, the first - // non-nested > is taken as the ending delimiter rather than a - // greater-than operator. [...] - if (GreaterThanIsOperator) - return prec::Relational; - return prec::Unknown; - - case tok::greatergreater: - // C++0x [temp.names]p3: - // - // [...] Similarly, the first non-nested >> is treated as two - // consecutive but distinct > tokens, the first of which is - // taken as the end of the template-argument-list and completes - // the template-id. [...] - if (GreaterThanIsOperator || !CPlusPlus0x) - return prec::Shift; - return prec::Unknown; - - default: return prec::Unknown; - case tok::comma: return prec::Comma; - case tok::equal: - case tok::starequal: - case tok::slashequal: - case tok::percentequal: - case tok::plusequal: - case tok::minusequal: - case tok::lesslessequal: - case tok::greatergreaterequal: - case tok::ampequal: - case tok::caretequal: - case tok::pipeequal: return prec::Assignment; - case tok::question: return prec::Conditional; - case tok::pipepipe: return prec::LogicalOr; - case tok::ampamp: return prec::LogicalAnd; - case tok::pipe: return prec::InclusiveOr; - case tok::caret: return prec::ExclusiveOr; - case tok::amp: return prec::And; - case tok::exclaimequal: - case tok::equalequal: return prec::Equality; - case tok::lessequal: - case tok::less: - case tok::greaterequal: return prec::Relational; - case tok::lessless: return prec::Shift; - case tok::plus: - case tok::minus: return prec::Additive; - case tok::percent: - case tok::slash: - case tok::star: return prec::Multiplicative; - case tok::periodstar: - case tok::arrowstar: return prec::PointerToMember; - } -} - - /// \brief Simple precedence-based parser for binary/ternary operators. /// /// Note: we diverge from the C99 grammar when parsing the assignment-expression |