aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMikhail Glushenkov <foldr@codedgers.com>2009-10-17 20:08:30 +0000
committerMikhail Glushenkov <foldr@codedgers.com>2009-10-17 20:08:30 +0000
commit95b99cae40c20a3fa2da3ee0e58e29d4e21701ed (patch)
tree28c349c9a87ecb7661a0503840b0ef9b984405cf
parentcbe1e4185d46cf2c8bfc2413595490285665e82a (diff)
downloadexternal_llvm-95b99cae40c20a3fa2da3ee0e58e29d4e21701ed.zip
external_llvm-95b99cae40c20a3fa2da3ee0e58e29d4e21701ed.tar.gz
external_llvm-95b99cae40c20a3fa2da3ee0e58e29d4e21701ed.tar.bz2
Disallow multiple instances of PluginPriority.
Several instances of PluginPriority in a single file most probably signifies a programming error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84350 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/LLVMC/MultiplePluginPriorities.td10
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp14
2 files changed, 20 insertions, 4 deletions
diff --git a/test/LLVMC/MultiplePluginPriorities.td b/test/LLVMC/MultiplePluginPriorities.td
new file mode 100644
index 0000000..721b7cc
--- /dev/null
+++ b/test/LLVMC/MultiplePluginPriorities.td
@@ -0,0 +1,10 @@
+// Check that multiple plugin priorities are not allowed.
+// RUN: ignore tblgen -I %p/../../include --gen-llvmc %s |& grep "More than one 'PluginPriority' instance found"
+
+include "llvm/CompilerDriver/Common.td"
+
+def Graph : CompilationGraph<[]>;
+
+def Priority1 : PluginPriority<1>;
+
+def Priority2 : PluginPriority<2>;
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 06afaf7..6dfd1b3 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -775,11 +775,17 @@ void FillInEdgeVector(RecordVector::const_iterator B,
/// CalculatePriority - Calculate the priority of this plugin.
int CalculatePriority(RecordVector::const_iterator B,
RecordVector::const_iterator E) {
- int total = 0;
- for (; B!=E; ++B) {
- total += static_cast<int>((*B)->getValueAsInt("priority"));
+ int priority = 0;
+
+ if (B != E) {
+ priority = static_cast<int>((*B)->getValueAsInt("priority"));
+
+ if (++B != E)
+ throw std::string("More than one 'PluginPriority' instance found: "
+ "most probably an error!");
}
- return total;
+
+ return priority;
}
/// NotInGraph - Helper function object for FilterNotInGraph.