From 8249a8889dbe5ef41c3367cca2d1f541b9c47081 Mon Sep 17 00:00:00 2001 From: Don Hinton Date: Thu, 16 May 2019 16:25:13 +0000 Subject: [CommandLine] Don't allow duplicate categories. Summary: This is a fix to D61574, r360179, that allowed duplicate OptionCategory's. This change adds a check to make sure a category can only be added once even if the user passes it twice. Reviewed By: MaskRay Tags: #llvm Differential Revision: https://reviews.llvm.org/D61972 llvm-svn: 360913 --- llvm/lib/Support/CommandLine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'llvm/lib/Support/CommandLine.cpp') diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 4e63a07..3d82f15 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -450,7 +450,7 @@ void Option::addCategory(OptionCategory &C) { // must be explicitly added if you want multiple categories that include it. if (&C != &GeneralCategory && Categories[0] == &GeneralCategory) Categories[0] = &C; - else + else if (find(Categories, &C) == Categories.end()) Categories.push_back(&C); } -- cgit v1.1