summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: Fix incorrect cast detection.Daniel Jasper2015-11-231-0/+1
| | | | | | | | | | Before: bool b = f(g<int>)&&c; After: bool b = f(g<int>) && c; llvm-svn: 253872
* clang-format: If the template list of a variable declaration spansDaniel Jasper2015-11-231-1/+2
| | | | | | | | | | | | | | | multiple lines, also break before the variable name. Before: std::vector<aaaaaa, // wrap aa> aaa; After: std::vector<aaaaaa, // wrap aa> aaa; llvm-svn: 253871
* clang-format: Make moving of the Cursor work properly when sorting #includes.Daniel Jasper2015-11-231-0/+20
| | | | llvm-svn: 253860
* Fix calculation of shifted cursor/code positions. Specifically supportDaniel Jasper2015-11-231-6/+15
| | | | | | | | | the case where a specific range is replaced by new text. Previously, the calculation would shift any position from within a replaced region to the first character after the region. This is undersirable, e.g. for clang-format's include sorting. llvm-svn: 253859
* clang-format: Make sorting includes respect // clang-format offDaniel Jasper2015-11-211-0/+19
| | | | llvm-svn: 253772
* clang-format: [JS] Make AllowShortFunctionsOnASingle line value "Empty"Daniel Jasper2015-11-201-0/+6
| | | | | | work properly. llvm-svn: 253674
* clang-format: [JS] Properly add a space after "in" in for loops.Daniel Jasper2015-11-201-0/+5
| | | | llvm-svn: 253672
* clang-format: [JS] struct and union aren't keywords / reserved words.Daniel Jasper2015-11-201-0/+2
| | | | llvm-svn: 253671
* clang-format: Don't use incorrect space in macro calls with operators.Daniel Jasper2015-11-201-0/+2
| | | | | | | | | | | | Before: MACRO(> ); After: MACRO(>); Not overly important, but easy and good for symmetry reasons :-). llvm-svn: 253669
* clang-format: [Proto] Support extending message.Daniel Jasper2015-11-201-0/+5
| | | | | | | | | | | | Before: extend.foo.Bar { } After: extend .foo.Bar { } llvm-svn: 253667
* Removing the AST matcher test for thread_local storage duration. Not all ↵Aaron Ballman2015-11-181-5/+5
| | | | | | platforms support TLS, and on platforms that do not support it, use of thread_local causes an error. Since there's no way to determine whether the testing platform supports TLS, there's no way to know whether the test is safe to run or not. I will explore ways to enable this test, but this will appease at least one more build bot. llvm-svn: 253486
* Re-committing r253473 after hopefully fixing the bot breakage. There was a ↵Aaron Ballman2015-11-181-0/+23
| | | | | | copy-pasta issue that my local testing did not catch. llvm-svn: 253481
* Reverting r253473 while I investigate build bot failures.Aaron Ballman2015-11-181-23/+0
| | | | llvm-svn: 253475
* Adding AST matchers for VarDecl storage durations. Can now determine whether ↵Aaron Ballman2015-11-181-0/+23
| | | | | | a VarDecl has automatic, static, or thread storage duration. This also updates the documentation for matchers, which appear to be missing some previous additions. llvm-svn: 253473
* [libclang] Add entry points that take a full command line including argv[0].Benjamin Kramer2015-11-181-0/+26
| | | | | | | | | | | | This provides both a more uniform interface and makes libclang behave like clang tooling wrt relative paths against argv[0]. This is necessary for finding paths to a c++ standard library relative to a clang binary given in a compilation database. It can also be used to find paths relative to libclang.so if the full path to it is passed in. Differential Revision: http://reviews.llvm.org/D14695 llvm-svn: 253466
* [CUDA] Make CUDA compilation usable by default.Artem Belevich2015-11-171-0/+1
| | | | | | | | | | | | | | | | | | Currently clang requires several additional command line options in order to enable new features needed during CUDA compilation. This patch makes these options default. * Automatically include cuda_runtime.h if we've found a valid CUDA installation. * Disable automatic CUDA header inclusion during unit tests. * Added test case for command line construction. * Enabled target overloads and relaxed call checks that are needed in order to include CUDA headers. * Added CUDA-7.5 installation path to the CUDA installation search list. * Define __CUDA__ macro to indicate CUDA compilation. llvm-svn: 253389
* clang-format: Enable #include sorting by default.Daniel Jasper2015-11-162-0/+12
| | | | | | | | | This has seen quite some usage and I am not aware of any issues. Also add a style option to enable/disable include sorting. The existing command line flag can from now on be used to override whatever is set in the style. llvm-svn: 253202
* Adjust printQualifiedName to handle unscoped enums in a way similar to ↵Alexander Kornienko2015-11-091-0/+42
| | | | | | | | | | anonymous namespaces. Patch by Sterling Augustine! Differential revision: http://reviews.llvm.org/D14459 llvm-svn: 252488
* Make ArgumentAdjuster aware of the current file being processed.Alexander Kornienko2015-11-051-1/+1
| | | | | | | | | | | | | | Summary: This is needed to handle per-project configurations when adding extra arguments in clang-tidy for example. Reviewers: klimek, djasper Subscribers: djasper, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14191 llvm-svn: 252134
* Make hasLHS and hasRHS matchers available for ArraySubscriptExprAlexander Kornienko2015-11-021-0/+5
| | | | | | | | | | | | | | Summary: The hasBase and hasIndex don't tell anything about the position of the base and the index in the code, so we need hasLHS and hasRHS in some cases. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14212 llvm-svn: 251842
* clang-format: Simplify and improve stop condition for formattingDaniel Jasper2015-11-021-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | unaffected lines with incorrect initial indent. Starting from: namespace { int i; // There shouldn't be indentation here. int j; // <- call clang-format on this line. } Before: namespace { int i; int j; } After: namespace { int i; int j; } llvm-svn: 251824
* clang-format: Be slightly more cautious when formatting subsequent lines ↵Daniel Jasper2015-11-011-0/+21
| | | | | | | | | | | | | | | | | after a change. With r251474, clang-format could indent the entire rest of the file, if there is a missing closing brace, e.g. while writing code in an editor. Summary: With this change, clang-format stops formatting when either it leaves the current scope or when it comes back to the initial scope after going into a nested one. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14213 llvm-svn: 251760
* Add "equalsNode" for types and "isCopyAssignmentOperator" matchers.Angel Garcia Gomez2015-10-301-0/+29
| | | | | | | | | | | | Summary: This matchers are going to be used in modernize-use-default, but are generic enough to be placed in ASTMatchers.h. Reviewers: klimek Subscribers: alexfh, cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14152 llvm-svn: 251693
* Format: support inline namespacesSaleem Abdulrasool2015-10-301-0/+7
| | | | | | | | Correct handling for C++17 inline namespaces. We would previously fail to identify the inline namespaces as a namespace name since multiple ones may be concatenated now with C++17. llvm-svn: 251690
* clang-format: [JS] Add goog.setTestOnly to the list of stuff thatDaniel Jasper2015-10-291-0/+2
| | | | | | is import-statement-like and shouldn't be wrapped. llvm-svn: 251643
* clang-format: When a line is formatted, also format subsequence lines if ↵Daniel Jasper2015-10-281-8/+18
| | | | | | | | | | | | | | their indent is off. Summary: This is especially important so that if a change is solely inserting a block around a few statements, clang-format-diff.py will still clean up and add indentation to the inner parts. Reviewers: klimek Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D14105 llvm-svn: 251474
* Minor fix in ToolChainTest.cpp to allow user defined GCC toolchain.Samuel Antao2015-10-271-4/+4
| | | | | | | If the user configured clang with a custom GCC toolchain that will take precedence on what the ToolChainTest.cpp expects to evaluate. This is fixed here by passing --gcc-toolchain= to the driver, in order to override any user defined GCC toolchain. llvm-svn: 251459
* clang-format: Undo unwanted format change done in r251405.Daniel Jasper2015-10-271-0/+5
| | | | | | | | Specifically, don't wrap between the {} of an empty constructor if the "}" falls on column 81 and ConstructorInitializerAllOnOneLineOrOnePerLine is set. llvm-svn: 251406
* clang-format: Add an additional value to AlignAfterOpenBracket: AlwaysBreak.Daniel Jasper2015-10-272-56/+82
| | | | | | | | | | | | | | | | | | | | Summary: If this option is set, clang-format will always insert a line wrap, e.g. before the first parameter of a function call unless all parameters fit on the same line. This obviates the need to make a decision on the alignment itself. Use this style for Google's JavaScript style and add some minor tweaks to correctly handle nested blocks etc. with it. Don't use this option for for/while loops. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D14104 llvm-svn: 251405
* clang-format: Fix false positive in cast detection.Daniel Jasper2015-10-261-0/+5
| | | | | | | | | | Before (with spaces in parentheses): void inFunction() { std::function<void( int, int )> fct; } After: void inFunction() { std::function<void( int, int)> fct; } llvm-svn: 251284
* [AST] Re-add TypeLocs and NestedNameSpecifierLocs to the ParentMap.Benjamin Kramer2015-10-233-4/+23
| | | | | | | | | | | | | | | | | | | | This relands r250831 after some fixes to shrink the ParentMap overall with one addtional tweak: nodes with pointer identity (e.g. Decl* and friends) can be store more efficiently so I put them in a separate map. All other nodes (so far only TypeLoc and NNSLoc) go in a different map keyed on DynTypedNode. This further uglifies the code but significantly reduces memory overhead. Overall this change still make ParentMap significantly larger but it's nowhere as bad as before. I see about 25 MB over baseline (pre-r251008) on X86ISelLowering.cpp. If this becomes an issue we could consider splitting the maps further as DynTypedNode is still larger (32 bytes) than a single TypeLoc (16 bytes) but I didn't want to introduce even more complexity now. Differential Revision: http://reviews.llvm.org/D14011 llvm-svn: 251101
* [Tooling] Add a utility function to replace one nested name with another.Benjamin Kramer2015-10-222-0/+109
| | | | | | | | | | | | | | | | One problem in clang-tidy and other clang tools face is that there is no way to lookup an arbitrary name in the AST, that's buried deep inside Sema and might not even be what the user wants as the new name may be freshly inserted and not available in the AST. A common use case for lookups is replacing one nested name with another while minimizing namespace qualifications, so replacing 'ns::foo' with 'ns::bar' will use just 'bar' if we happen to be inside the namespace 'ns'. This adds a little helper utility for exactly that use case. Differential Revision: http://reviews.llvm.org/D13931 llvm-svn: 251022
* clang-format: Teach --sort-includes to interleave #include and #import.Nico Weber2015-10-211-0/+9
| | | | | | | | | | clang accepts both #include and #import for includes (the latter having an implicit header guard). Let clang-format interleave both types if --sort-includes is passed. #import is used frequently in Objective-C code. http://reviews.llvm.org/D13853 llvm-svn: 250909
* Shrink DynTypedNode by one pointer from 40 to 32 bytes (on x86_64).Benjamin Kramer2015-10-211-2/+2
| | | | | | | | | | | | | | | | | | The MemoizationData cache was introduced to avoid a series of enum compares at the cost of making DynTypedNode bigger. This change reverts to using an enum compare but instead of building a chain of comparison the enum values are reordered so the check can be performed with a simple greater than. The alternative would be to steal a bit from the enum but I think that's a more complex solution and not really needed here. I tried this on several large .cpp files with clang-tidy and didn't notice any performance difference. The test change is due to matchers being sorted by their node kind. Differential Revision: http://reviews.llvm.org/D13946 llvm-svn: 250905
* Revert "[AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap."Benjamin Kramer2015-10-213-23/+5
| | | | | | | | | | | | Putting DynTypedNode in the ParentMap bloats its memory foot print. Before the void* key had 8 bytes, now we're at 40 bytes per key which can mean multiple gigabytes increase for large ASTs and this count doesn't even include all the added TypeLoc nodes. Revert until I come up with a better data structure. This reverts commit r250831. llvm-svn: 250889
* [AST] Put TypeLocs and NestedNameSpecifierLocs into the ParentMap.Benjamin Kramer2015-10-203-5/+23
| | | | | | | | | | | | | | | | Firstly this changes the type of parent map to be keyed on DynTypedNode to simplify the following changes. This comes with a DenseMapInfo for DynTypedNode, which is a bit incomplete still and will probably only work for parentmap right now. Then the RecursiveASTVisitor in ASTContext is updated and finally ASTMatchers hasParent and hasAncestor learn about the new functionality. Now ParentMap is only missing TemplateArgumentLocs and CXXCtorInitializers. Differential Revision: http://reviews.llvm.org/D13897 llvm-svn: 250831
* Roll-back r250822.Angel Garcia Gomez2015-10-206-7/+7
| | | | | | | | | | Summary: It breaks the build for the ASTMatchers Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13893 llvm-svn: 250827
* Apply modernize-use-default to clang.Angel Garcia Gomez2015-10-206-7/+7
| | | | | | | | | | | | Summary: Replace empty bodies of default constructors and destructors with '= default'. Reviewers: bkramer, klimek Subscribers: klimek, alexfh, cfe-commits Differential Revision: http://reviews.llvm.org/D13890 llvm-svn: 250822
* Revert accidental commit. This isn't ready yet.Benjamin Kramer2015-10-201-1/+0
| | | | llvm-svn: 250804
* Put back dead code that's used out-of-tree.Benjamin Kramer2015-10-201-0/+1
| | | | | | Partially reverts r250418. llvm-svn: 250803
* clang-format: Extend main header include sorting heuristic to Objective-C files.Nico Weber2015-10-191-0/+7
| | | | llvm-svn: 250675
* clang-format: [JS] Handle string literals spanning character classes.Daniel Jasper2015-10-181-0/+10
| | | | | | | | | | | | | | | If a RegExp contains a character group with a quote (/["]/), the trailing end of it is first tokenized as a string literal, which leads to the merging code seeing an unbalanced bracket. This change parses regex literals from the left hand side. That simplifies the parsing code and also allows correctly handling escapes and character classes, hopefully correctly parsing all regex literals. Patch by Martin Probst, thank you. Review: http://reviews.llvm.org/D13765 llvm-svn: 250648
* Add an AST node matcher for TemplateTypeParmDecl objects.Eric Fiselier2015-10-171-0/+7
| | | | llvm-svn: 250602
* clang-format/java: Break after annotations on fields in Chromium style.Nico Weber2015-10-151-0/+4
| | | | | | | | | | | Chromium follows the Android style guide for Java code, and that doesn't make the distinction between fields and non-fields that the Google Java style guide makes: https://source.android.com/source/code-style.html#use-standard-java-annotations https://google.github.io/styleguide/javaguide.html#s4.8.5-annotations llvm-svn: 250422
* [Driver] Use the parent_path of the clang executable as the default InstalledDirBenjamin Kramer2015-10-131-2/+41
| | | | | | | | This is what most people want anyways. Clang -cc1's main() will override this but for other tools this is the most sensible default and avoids some work. llvm-svn: 250164
* Add decayedType and hasDecayedType AST matchersMatthias Gehre2015-10-121-0/+5
| | | | | | | | | | | | Summary: Add decayedType and hasDecayedType AST matchers Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D13639 llvm-svn: 250114
* [VFS] Let the user decide if they want path normalization.Benjamin Kramer2015-10-121-2/+31
| | | | | | | | | | | | | | This is a more principled version of what I did earlier. Path normalization is generally a good thing, but may break users in strange environments, e. g. using lots of symlinks. Let the user choose and default it to on. This also changes adding a duplicated file into returning an error if the file contents are different instead of an assertion failure. Differential Revision: http://reviews.llvm.org/D13658 llvm-svn: 250060
* [VFS] Unbreak test.Benjamin Kramer2015-10-121-2/+0
| | | | llvm-svn: 250037
* [VFS] Don't try to be heroic with '.' in paths.Benjamin Kramer2015-10-121-5/+3
| | | | | | | Actually the only special path we have to handle is ./foo, the rest is tricky to get right so do the same thing as the existing YAML vfs here. llvm-svn: 250036
* [VFS] remove handling of '..' for now.Benjamin Kramer2015-10-121-3/+0
| | | | | | | | | This can fail badly if we're overlaying a real file system and there are symlinks there. Just keep the path as-is for now. This essentially reverts r249830. llvm-svn: 250021
OpenPOWER on IntegriCloud