This patch introduced the ability to decide at runtime whether to parse
JSON compilation database command lines using Gnu syntax or Windows
syntax. However, there were many existing unit tests written that
hardcoded Gnu-specific paths. These tests were now failing because
the auto-detection logic was choosing to parse them using Windows
rules.
This resubmission of the patch fixes this by introducing an enum
which defines the syntax mode, which defaults to auto-detect, but
for which the unit tests force Gnu style parsing.
Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D23628
llvm-svn: 279120
This complements the clang_getSkippedRanges function which returns skipped ranges filtered by a specific file.
This function is useful when all the ranges are desired (and a lot more efficient than the equivalent of asking for the ranges file by file, since the implementation of clang_getSkippedRanges iterates over all ranges anyway).
Differential Revision: https://reviews.llvm.org/D20132
llvm-svn: 279076
Summary:
rL277342 made RecursiveASTVisitor visit lambda capture initialization
expressions (these are the Exprs in LambdaExpr::capture_inits()).
jdennett identified two issues with rL277342 (see comments there for details):
- It visits initialization expressions for implicit lambda captures, even if
shouldVisitImplicitCode() returns false.
- It visits initialization expressions for init captures twice (because these
were already traveresed in TraverseLambdaCapture() before rL277342)
This patch fixes these issues and moves the code for traversing initialization
expressions into TraverseLambdaCapture().
This patch also makes two changes required for the tests:
- It adds Lang_CXX14 to the Language enum in TestVisitor.
- It adds a parameter to ExpectedLocationVisitor::ExpectMatch() that specifies
the number of times a match is expected to be seen.
Reviewers: klimek, jdennett, alexfh
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D23204
llvm-svn: 278933
Currently, if --driver-mode is not passed at all, it will default
to GCC style driver. This is never an issue for clang because
it manually constructs a --driver-mode option and passes it.
However, we should still try to do as good as we can even if no
--driver-mode is passed. LibTooling, for example, does not pass
a --driver-mode option and while it could, it seems like we should
still fallback to the best possible default we can.
This is one of two steps necessary to get clang-tidy working on Windows.
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D23454
llvm-svn: 278535
Summary: When sorting #includes, #include directives that have the same text will be deduplicated when sorting #includes, and only the first #include in the duplicate #includes remains. If the `Cursor` is provided and put on a deleted #include, it will be put on the remaining #include in the duplicate #includes.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D23274
llvm-svn: 278206
Summary:
This is required for compliance with the Mozilla style guide.
This is a rebase+minor change of Birunthan Mohanathas's patch
Reviewers: djasper
Subscribers: klimek, cfe-commits, opilarium
Differential Revision: https://reviews.llvm.org/D23317
llvm-svn: 278121
Previously, we would search through all replacements when inserting a
new one to check for overlaps. Instead, make use of the fact that we
already have a set of replacments without overlaps to find the potential
overlap with lower_bound.
Differential Revision: https://reviews.llvm.org/D23119
llvm-svn: 277597
Summary:
Lambda capture initializations are part of the explicit source code and
therefore should be visited by default but, so far, RecursiveASTVisitor does not
visit them.
This appears to be an oversight. Because the lambda body needs custom handling
(calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets
ShouldVisitChildren to false but then neglects to visit the lambda capture
initializations. This patch adds code to visit the expressions associated with
lambda capture initializations.
Reviewers: klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D22566
llvm-svn: 277342
Summary:
- Implement clang::tooling::Replacements as a class to provide interfaces to
control how replacements for a single file are combined and provide guarantee
on the order of replacements being applied.
- tooling::Replacements only contains replacements for the same file now.
Use std::map<std::string, tooling::Replacements> to represent multi-file
replacements.
- Error handling for the interface change will be improved in followup patches.
Reviewers: djasper, klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D21748
llvm-svn: 277335
Summary:
Lambda capture initializations are part of the explicit source code and therefore should be visited by default but, so far, RecursiveASTVisitor does not visit them.
This appears to be an oversight. Because the lambda body needs custom handling (calling TraverseLambdaBody()), the DEF_TRAVERSE_STMT for LambdaExpr sets ShouldVisitChildren to false but then neglects to visit the lambda capture initializations. This patch adds code to visit the expressions associated with lambda capture initializations.
Reviewers: klimek
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D22566
llvm-svn: 276755
Summary:
[Tooling] skip anonymous namespaces when checking if typeLoc
references a type decl from a different canonical namespace.
Reviewers: bkramer
Subscribers: cfe-commits, klimek
Differential Revision: https://reviews.llvm.org/D22808
llvm-svn: 276754
I am not sure exactly which test breakage Martin was trying to fix in
r273694. For now, fix the behavior for top-level conditionals, which
(surprisingly) are actually used somewhat commonly.
llvm-svn: 275183
Summary:
return llvm::Expected<> to carry error status and error information.
This is the first step towards introducing "Error" into tooling::Replacements.
Reviewers: djasper, klimek
Subscribers: ioeric, klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21601
llvm-svn: 275062
Summary: ASCII case sorting does not help finding imported symbols quickly, and it is common to have e.g. class Foo and function fooFactory exported/imported from the same file.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D22146
llvm-svn: 274977
Summary:
CFG generation is expected to fail in this case, but it should not crash.
Also added a test that reproduces the crash.
Reviewers: klimek
Subscribers: cfe-commits
Patch by Martin Boehme!
Differential Revision: http://reviews.llvm.org/D21895
llvm-svn: 274834
Original commit message:
"Add postorder traversal support to the RecursiveASTVisitor.
This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.
Patch by Raphael Isemann!
Reviewed by Richard Smith and Benjamin Kramer."
llvm-svn: 274830
This feature needs to be explicitly enabled by overriding shouldTraversePostOrder()
as it has performance drawbacks for the iterative Stmt-traversal.
Patch by Raphael Isemann!
Reviewed by Richard Smith and Benjamin Kramer.
llvm-svn: 274348
It was failing because it had an explicit check for whether we're on
Windows.
There are a few other similar explicit checks in this file which I
didn't remove because they serve as reasonable documentation that the
test doesn't work with a Windows triple.
llvm-svn: 274269
Summary:
This test was stat()'ing large swaths of /usr/lib hundreds of times, as
every invocation of matchesConditionally*() created a new Linux
toolchain.
In addition to being slow, perf indicated this was causing substantial
contention in the kernel.
Something is...interesting in the kernel, as without this patch I
sometimes see ~11m spent in the kernel, and sometimes ~5m. This
corresponds to bimodal ninja check-clang times of ~30s and ~20s.
It's not clear to me exactly what causes the bimodality. In any case,
this change makes this test run in 2.5s, down from 17s, and it seems to
cause us to get the 20s ninja check-clang time unconditionally.
Reviewers: chandlerc
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D21810
llvm-svn: 274257
Summary: Includes parenthesized type expressions and type aliases.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21597
llvm-svn: 273603
Summary:
'as' is a pseudo operator, so automatic semicolon insertion kicks in and the
code fails to part.
Reviewers: djasper
Subscribers: klimek
Differential Revision: http://reviews.llvm.org/D21576
llvm-svn: 273422