From 2cea7bdef905f85845eb60ad87d272cc4bd54287 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Sat, 17 Oct 2009 20:08:30 +0000 Subject: 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 --- utils/TableGen/LLVMCConfigurationEmitter.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'utils') 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((*B)->getValueAsInt("priority")); + int priority = 0; + + if (B != E) { + priority = static_cast((*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. -- cgit v1.1