summaryrefslogtreecommitdiff
path: root/lib/IR/AsmWriter.cpp
diff options
context:
space:
mode:
authorGuy Benyei <guy.benyei@intel.com>2013-02-12 21:21:59 +0000
committerGuy Benyei <guy.benyei@intel.com>2013-02-12 21:21:59 +0000
commit87d0b9ed1462705dd9bf1cb7f67d0bf03af776c8 (patch)
tree54c1b122b1f937a363b1ce4a1e091e795d575785 /lib/IR/AsmWriter.cpp
parent5f3c4a39109479e81238ce28e91e5dcc565f068c (diff)
downloadllvm-87d0b9ed1462705dd9bf1cb7f67d0bf03af776c8.tar.gz
llvm-87d0b9ed1462705dd9bf1cb7f67d0bf03af776c8.tar.bz2
llvm-87d0b9ed1462705dd9bf1cb7f67d0bf03af776c8.tar.xz
Add static cast to unsigned char whenever a character classification function is called with a signed char argument, in order to avoid assertions in Windows Debug configuration.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175006 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/IR/AsmWriter.cpp')
-rw-r--r--lib/IR/AsmWriter.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp
index bf893e855e..17d49ac410 100644
--- a/lib/IR/AsmWriter.cpp
+++ b/lib/IR/AsmWriter.cpp
@@ -117,7 +117,7 @@ static void PrintLLVMName(raw_ostream &OS, StringRef Name, PrefixType Prefix) {
}
// Scan the name to see if it needs quotes first.
- bool NeedsQuotes = isdigit(Name[0]);
+ bool NeedsQuotes = isdigit(static_cast<unsigned char>(Name[0]));
if (!NeedsQuotes) {
for (unsigned i = 0, e = Name.size(); i != e; ++i) {
// By making this unsigned, the value passed in to isalnum will always be
@@ -125,7 +125,8 @@ static void PrintLLVMName(raw_ostream &OS, StringRef Name, PrefixType Prefix) {
// its implementation will assert. This situation can arise when dealing
// with UTF-8 multibyte characters.
unsigned char C = Name[i];
- if (!isalnum(C) && C != '-' && C != '.' && C != '_') {
+ if (!isalnum(static_cast<unsigned char>(C)) && C != '-' && C != '.' &&
+ C != '_') {
NeedsQuotes = true;
break;
}
@@ -1392,14 +1393,16 @@ void AssemblyWriter::printNamedMDNode(const NamedMDNode *NMD) {
if (Name.empty()) {
Out << "<empty name> ";
} else {
- if (isalpha(Name[0]) || Name[0] == '-' || Name[0] == '$' ||
+ if (isalpha(static_cast<unsigned char>(Name[0])) ||
+ Name[0] == '-' || Name[0] == '$' ||
Name[0] == '.' || Name[0] == '_')
Out << Name[0];
else
Out << '\\' << hexdigit(Name[0] >> 4) << hexdigit(Name[0] & 0x0F);
for (unsigned i = 1, e = Name.size(); i != e; ++i) {
unsigned char C = Name[i];
- if (isalnum(C) || C == '-' || C == '$' || C == '.' || C == '_')
+ if (isalnum(static_cast<unsigned char>(C)) || C == '-' || C == '$' ||
+ C == '.' || C == '_')
Out << C;
else
Out << '\\' << hexdigit(C >> 4) << hexdigit(C & 0x0F);