diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-02-24 08:58:14 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-02-24 08:58:14 +0000 |
commit | 770dc0342c21f444b878d74ee5e1f4d25b5913a5 (patch) | |
tree | 5b959b72c9b8da60d5b819695033722ad96209b9 /lib/AST/Expr.cpp | |
parent | 28e4702a1f978213ff945fe4369e3be7444bf320 (diff) |
Silence gcc warnings pointing out that CharByteWidth could be used
uninitialized. While there, restyle this function! No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 37df90407d..f5dec75f6b 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -499,25 +499,28 @@ double FloatingLiteral::getValueAsApproximateDouble() const { return V.convertToDouble(); } -int StringLiteral::mapCharByteWidth(TargetInfo const &target,StringKind k) { +int StringLiteral::mapCharByteWidth(TargetInfo const &Target, + StringKind Kind) { int CharByteWidth; - switch(k) { + switch(Kind) { case Ascii: case UTF8: - CharByteWidth = target.getCharWidth(); + CharByteWidth = Target.getCharWidth(); break; case Wide: - CharByteWidth = target.getWCharWidth(); + CharByteWidth = Target.getWCharWidth(); break; case UTF16: - CharByteWidth = target.getChar16Width(); + CharByteWidth = Target.getChar16Width(); break; case UTF32: - CharByteWidth = target.getChar32Width(); + CharByteWidth = Target.getChar32Width(); + default: + llvm_unreachable("Don't know byte width of this string kind!"); } assert((CharByteWidth & 7) == 0 && "Assumes character size is byte multiple"); CharByteWidth /= 8; - assert((CharByteWidth==1 || CharByteWidth==2 || CharByteWidth==4) + assert((CharByteWidth == 1 || CharByteWidth == 2 || CharByteWidth == 4) && "character byte widths supported are 1, 2, and 4 only"); return CharByteWidth; } @@ -562,7 +565,7 @@ void StringLiteral::setString(ASTContext &C, StringRef Str, this->Kind = Kind; this->IsPascal = IsPascal; - CharByteWidth = mapCharByteWidth(C.getTargetInfo(),Kind); + CharByteWidth = mapCharByteWidth(C.getTargetInfo(), Kind); assert((Str.size()%CharByteWidth == 0) && "size of data must be multiple of CharByteWidth"); Length = Str.size()/CharByteWidth; |