[llvm-commits] [llvm] r84350 - in /llvm/trunk: test/LLVMC/MultiplePluginPriorities.td utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Sat Oct 17 13:08:31 PDT 2009
Author: foldr
Date: Sat Oct 17 15:08:30 2009
New Revision: 84350
URL: http://llvm.org/viewvc/llvm-project?rev=84350&view=rev
Log:
Disallow multiple instances of PluginPriority.
Several instances of PluginPriority in a single file most probably signifies a
programming error.
Added:
llvm/trunk/test/LLVMC/MultiplePluginPriorities.td
Modified:
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Added: llvm/trunk/test/LLVMC/MultiplePluginPriorities.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LLVMC/MultiplePluginPriorities.td?rev=84350&view=auto
==============================================================================
--- llvm/trunk/test/LLVMC/MultiplePluginPriorities.td (added)
+++ llvm/trunk/test/LLVMC/MultiplePluginPriorities.td Sat Oct 17 15:08:30 2009
@@ -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>;
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=84350&r1=84349&r2=84350&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Sat Oct 17 15:08:30 2009
@@ -775,11 +775,17 @@
/// 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.
More information about the llvm-commits
mailing list