diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-13 05:04:16 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-13 05:04:16 +0000 |
| commit | 80b3c8e32fd9d9b25cd24efc3ad1e6f433dc2371 (patch) | |
| tree | 70ac7caa00fe25f763698a01dd853724808960c2 /clang/lib | |
| parent | f24e6e747b687b561db7a6bfe3331ee7ce206dfa (diff) | |
| download | bcm5719-llvm-80b3c8e32fd9d9b25cd24efc3ad1e6f433dc2371.tar.gz bcm5719-llvm-80b3c8e32fd9d9b25cd24efc3ad1e6f433dc2371.zip | |
Fix part of PR12457. Patch by Justin Bogner!
llvm-svn: 183886
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 21fb4599664..84f7bfdf82b 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5691,6 +5691,40 @@ bool IntExprEvaluator::VisitCallExpr(const CallExpr *E) { return Success(Val.byteSwap(), E); } + case Builtin::BI__builtin_clz: + case Builtin::BI__builtin_clzl: + case Builtin::BI__builtin_clzll: { + APSInt Val; + if (!EvaluateInteger(E->getArg(0), Val, Info)) + return false; + if (!Val) + return Error(E); + + return Success(Val.countLeadingZeros(), E); + } + + case Builtin::BI__builtin_ctz: + case Builtin::BI__builtin_ctzl: + case Builtin::BI__builtin_ctzll: { + APSInt Val; + if (!EvaluateInteger(E->getArg(0), Val, Info)) + return false; + if (!Val) + return Error(E); + + return Success(Val.countTrailingZeros(), E); + } + + case Builtin::BI__builtin_popcount: + case Builtin::BI__builtin_popcountl: + case Builtin::BI__builtin_popcountll: { + APSInt Val; + if (!EvaluateInteger(E->getArg(0), Val, Info)) + return false; + + return Success(Val.countPopulation(), E); + } + case Builtin::BI__builtin_classify_type: return Success(EvaluateBuiltinClassifyType(E), E); |

