summaryrefslogtreecommitdiffstats
path: root/llvm/utils
diff options
context:
space:
mode:
authorMichael Ilseman <milseman@apple.com>2014-12-12 21:48:03 +0000
committerMichael Ilseman <milseman@apple.com>2014-12-12 21:48:03 +0000
commit5be22a12c2fdb4e13ead4b2e8a8a68f07fb1f270 (patch)
treed32cd1ee5853b7b127f7bc8acbb58e753c5feccd /llvm/utils
parent90482a77b114ba612951233d90f0173d7b7d04a6 (diff)
downloadbcm5719-llvm-5be22a12c2fdb4e13ead4b2e8a8a68f07fb1f270.tar.gz
bcm5719-llvm-5be22a12c2fdb4e13ead4b2e8a8a68f07fb1f270.zip
Clean up static analyzer warnings.
Clang's static analyzer found several potential cases of undefined behavior, use of un-initialized values, and potentially null pointer dereferences in tablegen, Support, MC, and ADT. This cleans them up with specific assertions on the assumptions of the code. llvm-svn: 224154
Diffstat (limited to 'llvm/utils')
-rw-r--r--llvm/utils/TableGen/CodeGenDAGPatterns.cpp4
-rw-r--r--llvm/utils/TableGen/CodeGenInstruction.cpp2
-rw-r--r--llvm/utils/TableGen/CodeGenRegisters.cpp1
3 files changed, 5 insertions, 2 deletions
diff --git a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
index 8b90d16d731..c3de37e9453 100644
--- a/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -2569,8 +2569,10 @@ FindPatternInputsAndOutputs(TreePattern *I, TreePatternNode *Pat,
I->error("set destination should be a register!");
DefInit *Val = dyn_cast<DefInit>(Dest->getLeafValue());
- if (!Val)
+ if (!Val) {
I->error("set destination should be a register!");
+ continue;
+ }
if (Val->getDef()->isSubClassOf("RegisterClass") ||
Val->getDef()->isSubClassOf("ValueType") ||
diff --git a/llvm/utils/TableGen/CodeGenInstruction.cpp b/llvm/utils/TableGen/CodeGenInstruction.cpp
index 7c5e6fcc9b9..4bea96927c7 100644
--- a/llvm/utils/TableGen/CodeGenInstruction.cpp
+++ b/llvm/utils/TableGen/CodeGenInstruction.cpp
@@ -537,7 +537,7 @@ bool CodeGenInstAlias::tryAliasOpMatch(DagInit *Result, unsigned AliasOpNo,
// If both are Operands with the same MVT, allow the conversion. It's
// up to the user to make sure the values are appropriate, just like
// for isel Pat's.
- if (InstOpRec->isSubClassOf("Operand") &&
+ if (InstOpRec->isSubClassOf("Operand") && ADI &&
ADI->getDef()->isSubClassOf("Operand")) {
// FIXME: What other attributes should we check here? Identical
// MIOperandInfo perhaps?
diff --git a/llvm/utils/TableGen/CodeGenRegisters.cpp b/llvm/utils/TableGen/CodeGenRegisters.cpp
index d252f76d939..bef8a4b8fa1 100644
--- a/llvm/utils/TableGen/CodeGenRegisters.cpp
+++ b/llvm/utils/TableGen/CodeGenRegisters.cpp
@@ -146,6 +146,7 @@ void CodeGenRegister::buildObjectGraph(CodeGenRegBank &RegBank) {
}
const std::string &CodeGenRegister::getName() const {
+ assert(TheDef && "no def");
return TheDef->getName();
}
OpenPOWER on IntegriCloud