Skip to content

Commit b143887

Browse files
author
andreasfertig
authored
Merge pull request andreasfertig#29 from andreasfertig/fixIssue28
Fixed andreasfertig#28: Multiple matchers rewrote a statement.
2 parents c361daa + ae12346 commit b143887

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

UserDefinedLiteralHandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ UserDefinedLiteralHandler::UserDefinedLiteralHandler(Rewriter& rewrite, MatchFin
2323
matcher.addMatcher(
2424
userDefinedLiteral(unless(anyOf(isExpansionInSystemHeader(),
2525
isMacroOrInvalidLocation(),
26-
hasAncestor(cxxOperatorCallExpr()),
2726
hasAncestor(userDefinedLiteral()),
2827
isTemplate,
2928
/* if we match the top-most CXXOperatorCallExpr we will see all
3029
descendants. So filter them here to avoid getting them multiple times */
3130
hasAncestor(cxxOperatorCallExpr()),
31+
hasAncestor(cxxStdInitializerListExpr()),
3232
hasLambdaAncestor,
3333
hasAncestor(ifStmt()),
3434
hasAncestor(switchStmt()),

tests/Issue28.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <string>
2+
#include <vector>
3+
4+
int main()
5+
{
6+
using namespace std::string_literals;
7+
8+
std::vector<std::string> foo{"foo"s, "bar"s};
9+
}

tests/Issue28.expect

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <string>
2+
#include <vector>
3+
4+
int main()
5+
{
6+
using namespace std::string_literals;
7+
8+
std::vector<std::string> foo{ std::initializer_list<std::basic_string<char> >{ std::operator""s("foo", 3ul), std::operator""s("bar", 3ul) } };
9+
}

0 commit comments

Comments
 (0)