Author: arphaman Date: Fri Dec 2 03:51:51 2016 New Revision: 288491 URL: http://llvm.org/viewvc/llvm-project?rev=288491&view=rev Log: [Frontend] Fix an issue where a quoted search path is incorrectly removed as a duplicate header search path
The commit r126167 started passing the First index into RemoveDuplicates, but forgot to update 0 to First in the loop that looks for the duplicate. This resulted in a bug where an -iquoted search path was incorrectly removed if you passed in the same path into -iquote and more than one time into -isystem. rdar://23991350 Differential Revision: https://reviews.llvm.org/D27298 Added: cfe/trunk/test/Frontend/include-duplicate-removal.c Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=288491&r1=288490&r2=288491&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original) +++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Dec 2 03:51:51 2016 @@ -526,7 +526,7 @@ static unsigned RemoveDuplicates(std::ve if (CurEntry.getDirCharacteristic() != SrcMgr::C_User) { // Find the dir that this is the same of. unsigned FirstDir; - for (FirstDir = 0; ; ++FirstDir) { + for (FirstDir = First;; ++FirstDir) { assert(FirstDir != i && "Didn't find dupe?"); const DirectoryLookup &SearchEntry = SearchList[FirstDir]; Added: cfe/trunk/test/Frontend/include-duplicate-removal.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/include-duplicate-removal.c?rev=288491&view=auto ============================================================================== --- cfe/trunk/test/Frontend/include-duplicate-removal.c (added) +++ cfe/trunk/test/Frontend/include-duplicate-removal.c Fri Dec 2 03:51:51 2016 @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -v -I%S/Inputs -iquote %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix -isystem %S/Inputs/SystemHeaderPrefix %s 2>&1 | FileCheck %s + +#include <test.h> + +// CHECK: ignoring duplicate directory +// CHECK-SAME: Inputs/SystemHeaderPrefix"{{$}} + +// CHECK: #include "..." +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} +// CHECK-NEXT: #include <...> +// CHECK-NEXT: {{.*}}Inputs{{$}} +// CHECK-NEXT: {{.*}}Inputs/SystemHeaderPrefix{{$}} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits