[include-fixer] For now, only add the first suggested include.
We used a std::set which made the picked include somewhat random (well,
lexicographically sorted). Make the behavior more consistent by always
picking the first one we found.
llvm-svn: 269028
diff --git a/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp b/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp
index 05fb890..09ee012 100644
--- a/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp
+++ b/clang-tools-extra/unittests/include-fixer/IncludeFixerTest.cpp
@@ -49,6 +49,7 @@
const std::vector<std::string> &ExtraArgs = std::vector<std::string>()) {
std::map<std::string, std::vector<std::string>> XrefsMap = {
{"std::string", {"<string>"}},
+ {"std::sting", {"\"sting\""}},
{"std::string::size_type", {"<string>"}},
{"a::b::foo", {"dir/otherdir/qux.h"}},
};
@@ -114,6 +115,11 @@
runIncludeFixer("a::b::foo bar;\n", IncludePath));
}
+TEST(IncludeFixer, MultipleMissingSymbols) {
+ EXPECT_EQ("#include <string>\nstd::string bar;\nstd::sting foo;\n",
+ runIncludeFixer("std::string bar;\nstd::sting foo;\n"));
+}
+
} // namespace
} // namespace include_fixer
} // namespace clang