summaryrefslogtreecommitdiffstats
path: root/clang/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* clang-format: [JS] Handle certain cases of ASI.Daniel Jasper2016-03-141-66/+121
| | | | | | | | | | | | | | Automatic Semicolon Insertion can only be properly handled by parsing source code. However conservatively catching just a few, common situations prevents breaking code during development, which greatly improves usability. JS code should still use semicolons, and ASI code should be flagged by a compiler or linter. Patch by Martin Probst. Thank you. llvm-svn: 263470
* Use an explicit instantiation to work around delayed template parsing for ↵Aaron Ballman2016-03-091-3/+3
| | | | | | MSVC-built bots. llvm-svn: 263041
* Adding new AST matchers for: addrLabelExpr, atomicExpr, ↵Aaron Ballman2016-03-093-1/+130
| | | | | | | | binaryConditionalOperator, designatedInitExpr, designatorCountIs, hasSyntacticForm, implicitValueInitExpr, labelDecl, opaqueValueExpr, parenListExpr, predefinedExpr, requiresZeroInitialization, and stmtExpr. Patch by Aleksei Sidorin. llvm-svn: 263027
* Turning on the /bigobj flag for two more files that will not link with MSVC ↵Aaron Ballman2016-03-082-0/+12
| | | | | | 2015 Win64 Debug due to the section limit. llvm-svn: 262938
* [ASTMatchers] Document that isAnyPointer() matcher also matches Objective-C ↵Felix Berger2016-03-061-0/+5
| | | | | | | | | | | | | | object pointers. Summary: Add test for Objective-C object pointer matching. Reviewers: aaron.ballman Subscribers: klimek Differential Revision: http://reviews.llvm.org/D17489 llvm-svn: 262806
* clang-format: [JS] Support destructuring assignments in for loops.Daniel Jasper2016-03-051-0/+4
| | | | | | | | | | | | Before: for (let { a, b } of x) { } After: for (let {a, b} of x) { } llvm-svn: 262776
* Make TargetInfo store an actual DataLayout instead of a string.James Y Knight2016-03-043-11/+16
| | | | | | | | | | | | | | Use it to calculate UserLabelPrefix, instead of specifying it (often incorrectly). Note that the *actual* user label prefix has always come from the DataLayout, and is handled within LLVM. The main thing clang's TargetInfo::UserLabelPrefix did was to set the #define value. Having these be different from each-other is just silly. Differential Revision: http://reviews.llvm.org/D17183 llvm-svn: 262737
* clang-format: Use stable_sort when sorting #includes.Daniel Jasper2016-03-031-4/+18
| | | | | | | Otherwise, clang-format can output useless replacements in the presence of identical #includes llvm-svn: 262630
* clang-format: [JS] Optionally re-quote string literals.Daniel Jasper2016-03-022-3/+34
| | | | | | | | | | | | | | | | | | | | | Turns "foo" into 'foo' (or vice versa, depending on configuration). This makes it more convenient to follow the Google JavaScript style guide: https://google.github.io/styleguide/javascriptguide.xml?showone=Strings#Strings This functionality is behind the option "JavaScriptQuotes", which can be: * "leave" (no re-quoting) * "single" (change to single quotes) * "double" (change to double quotes) This also changes single quoted JavaScript string literals to be treated as tok::string_literal, not tok::char_literal, which fixes two unrelated tests. Patch by Martin Probst. Thank you. llvm-svn: 262534
* [clang-format] Detect constructor initializers preceded by `noexcept`.Daniel Jasper2016-03-011-0/+3
| | | | | | Patch by Erik Kessler, thank you. llvm-svn: 262402
* FormatTests: Update libdeps corresponding to r262323.NAKAMURA Takumi2016-03-011-0/+1
| | | | llvm-svn: 262329
* Fix DLL build by adding required dependency.Manuel Klimek2016-03-011-0/+1
| | | | llvm-svn: 262324
* Add functions to apply replacements and reformat them.Manuel Klimek2016-03-013-1/+65
| | | | | | | | | | | | | | | | This is a commonly useful feature to have, and we have implemented it multiple times with different kinds of bugs. This implementation centralizes the idea in a set of functions that we can then use from the various tools. Reverts r262234, which is a revert of r262232, and puts the functions into FOrmat.h, as they are closely coupled to clang-format, and we otherwise introduce a cyclic dependency between libFormat and libTooling. Patch by Eric Liu. llvm-svn: 262323
* Optionally demote fatal errors to non-fatal errors.Manuel Klimek2016-03-011-0/+23
| | | | | | | | | | | | | | | | | | This behavior is enabled when the new CXTranslationUnit_KeepGoing option is passed to clang_parseTranslationUnit{,2}. It is geared towards use by IDEs and similar consumers of the clang-c API where fatal errors may arise when parsing incomplete code mid-edit, or when include paths are not properly configured yet. In such situations one still wants to get as much information as possible about a TU. Previously, the semantic analysis would not instantiate templates or report additional fatal errors after the first fatal error was encountered. Fixes PR24268. Patch by Milian Wolff. llvm-svn: 262318
* clang-format: Correctly apply wrap before multi-line RHS rule toDaniel Jasper2016-03-011-0/+4
| | | | | | | | | | | | | | | ternary expressions. Before: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; After: return aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ? aaaaa : bbbbbbbbbbbbbbb + cccccccccccccccc; llvm-svn: 262293
* clang-format: Increase the penalty for breaking between array subscripts.Daniel Jasper2016-03-011-0/+2
| | | | | | | | | | | | Before: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa] [a].aaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa[aaaaaaaaaaaaaaaaaaaaaaa][a] .aaaaaaaaaaaaaaaaaaaaaa(); llvm-svn: 262292
* clang-format: [JS] Support quoted object literal keys.Daniel Jasper2016-03-011-0/+7
| | | | | | | | | | | | | | | | | Before: var x = { a: a, b: b, 'c': c, }; After: var x = { a: a, b: b, 'c': c, }; llvm-svn: 262291
* Revert "Implement new interfaces for code-formatting when applying ↵Manuel Klimek2016-02-292-50/+0
| | | | | | | | replacements." This reverts commit r262232. llvm-svn: 262234
* Implement new interfaces for code-formatting when applying replacements.Manuel Klimek2016-02-292-0/+50
| | | | | | Patch by Eric Liu. llvm-svn: 262232
* clang-format: Don't format unrelated nested blocks.Daniel Jasper2016-02-291-0/+17
| | | | | | | | | | | | | | | With this change: SomeFunction( [] { int i; return i; // Format this line. }, [] { return 2; // Don't "fix" this. }); llvm-svn: 262216
* Revert "[VFS] Add 'overlay-relative' field to YAML files" and "[VFS] Fix ↵Bruno Cardoso Lopes2016-02-231-1/+1
| | | | | | | | | | | | | | | call to getVFSFromYAML in unittests" This reverts commit r261552 and r261556 because of failing unittests on windows: Failing Tests (4): Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.CaseInsensitive Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.DirectoryIteration Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.MappedFiles Clang-Unit :: Basic/BasicTests.exe/VFSFromYAMLTest.UseExternalName llvm-svn: 261613
* Lex: Return "" when HeaderMap::lookupFilename failsDuncan P. N. Exon Smith2016-02-231-4/+38
| | | | | | | | | | | | Change getString() to return Optional<StringRef>, and change lookupFilename() to return an empty string if either one of the prefix and suffix can't be found. This is a more robust follow-up to r261461, but it's still not entirely satisfactory. Ideally we'd report that the header map is corrupt; perhaps something for a follow-up. llvm-svn: 261596
* Lex: Check for 0 buckets on header map constructionDuncan P. N. Exon Smith2016-02-221-0/+9
| | | | | | | | Switch to using `isPowerOf2_32()` to check whether the buckets are a power of two, and as a side benefit reject loading a header map with no buckets. This is a follow-up to r261448. llvm-svn: 261585
* [ASTMatchers] Add matcher hasAnyName.Samuel Benzaquen2016-02-221-0/+13
| | | | | | | | | | | | Summary: Add matcher hasAnyName as an optimization over anyOf(hasName(),...) Reviewers: alexfh Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17163 llvm-svn: 261574
* [VFS] Fix call to getVFSFromYAML in unittestsBruno Cardoso Lopes2016-02-221-1/+1
| | | | | | Follow up from r261552 llvm-svn: 261556
* clang-format: [JS] treat forwardDeclare as an import/export statement.Daniel Jasper2016-02-221-0/+2
| | | | | | Patch by Martin Probst. Thank you. llvm-svn: 261528
* Lex: Never overflow the file in HeaderMap::lookupFilename()Duncan P. N. Exon Smith2016-02-211-0/+42
| | | | | | | | | | | | | | | | If a header map file is corrupt, the strings in the string table may not be null-terminated. The logic here previously relied on `MemoryBuffer` always being null-terminated, but this isn't actually guaranteed by the class AFAICT. Moreover, we're seeing a lot of crash traces at calls to `strlen()` inside of `lookupFilename()`, so something is going wrong there. Instead, use `strnlen()` to get the length, and check for corruption. Also remove code paths that could call `StringRef(nullptr)`. r261459 made these rather obvious (although they'd been there all along). llvm-svn: 261461
* Lex: Add a test for HeaderMap::lookupFileName()Duncan P. N. Exon Smith2016-02-201-0/+62
| | | | | | | | Add a simple test for `HeaderMap::lookupFileName()`. I'm planning to add better error checking in a moment, and I'll add more tests like this then. llvm-svn: 261455
* Lex: Check whether the header map buffer has space for the bucketsDuncan P. N. Exon Smith2016-02-201-0/+8
| | | | | | | | | | | | | Check up front whether the header map buffer has space for all of its declared buckets. There was already a check in `getBucket()`, but it had UB (comparing pointers that were outside of objects in the error path) and was insufficient (only checking for a single byte of the relevant bucket). I fixed the check, moved it to `checkHeader()`, and left a fixed version behind as an assertion. llvm-svn: 261449
* Lex: Check buckets on header map constructionDuncan P. N. Exon Smith2016-02-201-0/+9
| | | | | | | | If the number of buckets is not a power of two, immediately recognize the header map as corrupt, rather than waiting for the first lookup. I converted the later check to an assert. llvm-svn: 261448
* Lex: Add some unit tests for corrupt header mapsDuncan P. N. Exon Smith2016-02-202-0/+95
| | | | | | | | | | | | Split the implementation of `HeaderMap` into `HeaderMapImpl` so that we can write unit tests that don't depend on the `FileManager`, and then write a few tests that cover the types of corrupt header maps already detected. This also moves type and constant definitions from HeaderMap.cpp to HeaderMapTypes.h so that the test can access them. llvm-svn: 261446
* Remove use of builtin comma operator.Richard Trieu2016-02-181-1/+2
| | | | | | Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. llvm-svn: 261271
* Use Backend_EmitMCNull for null codegen unit tests.David L. Jones2016-02-181-1/+1
| | | | | | | | | | | | | | Using Backend_EmitLL attemps to create a file with an empty filename. This is problematic in certain environments: an empty filename may be illegal, or the default output path may not be writable (in the case where an empty filename would otherwise have some non-failing semantics). This patch switches to use Backend_EmitMCNull, which allows CodeGen to run, but does not attempt to create or write an output file. Differential Revision: http://reviews.llvm.org/D17405 llvm-svn: 261252
* File missed from r261222Serge Pavlov2016-02-181-0/+61
| | | | llvm-svn: 261223
* Avoid double deletion in Clang driver.Serge Pavlov2016-02-181-0/+2
| | | | | | | | | | | | | | | | Llvm module object is shared between CodeGenerator and BackendConsumer, in both classes it is stored as std::unique_ptr, which is not a good design solution and can cause double deletion error. Usually it does not occur because in BackendConsumer::HandleTranslationUnit the ownership of CodeGenerator over the module is taken away. If however this method is not called, the module is deleted twice and compiler crashes. As the module owned by BackendConsumer is always the same as CodeGenerator has, pointer to llvm module can be removed from BackendGenerator. Differential Revision: http://reviews.llvm.org/D15450 llvm-svn: 261222
* Add an AST matcher for real floating-point types. e.g., float, double, long ↵Aaron Ballman2016-02-181-0/+9
| | | | | | double, but not complex. llvm-svn: 261221
* Missing semicolons are kind of important. Who knew?Aaron Ballman2016-02-161-1/+1
| | | | llvm-svn: 261009
* Add a nullPointerConstant() AST matcher to handle variations of null pointer ↵Aaron Ballman2016-02-161-0/+10
| | | | | | constants in one matcher. llvm-svn: 261008
* Stop using "template" when printing qualtype namesReid Kleckner2016-02-161-1/+7
| | | | | | | | | | | | | | | | Summary: The keyword "template" isn't necessary when printing a fully-qualified qualtype name, and, in fact, results in a syntax error if one tries to use it. So stop printing it. Reviewers: rsmith, rnk Subscribers: rnk, klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D17214 llvm-svn: 261005
* Add isAnyPointer() matchers. Register missing matchers.Felix Berger2016-02-151-0/+8
| | | | | | | | | | | | | Summary: The isAnyPointer() matcher is useful for http://reviews.llvm.org/D15623. Reviewers: alexfh, klimek Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D15819 llvm-svn: 260872
* tests: Add explicit -stdlib=libstdc++ to tests that require itJonas Hahnfeld2016-02-121-1/+1
| | | | | | | This will be needed for the next commit that allows to switch the default C++ library which would otherwise make these tests fail. llvm-svn: 260661
* clang-format: [JS] Support for (.. of ..) loops.Daniel Jasper2016-02-111-0/+3
| | | | | | | | | | Before: for (var i of[2, 3]) {} After: for (var i of [2, 3]) {} llvm-svn: 260518
* clang-format: Make indentation after "<<" more consistent.Daniel Jasper2016-02-111-0/+7
| | | | | | | | | | | | | | | | | | | | | | Before: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; After: Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) << aaa; llvm-svn: 260517
* clang-format: Make it more expensive to break template parameters.Daniel Jasper2016-02-111-0/+5
| | | | | | | | | | | | | | | | | | In particular, make it more expensive than breaking after the return type of a function definition/declaration. Before: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa< T>::aaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); After: template <typename T> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaa<T>::aaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaa); llvm-svn: 260497
* Add Tooling functionality to get a name for a QualType that can be used to nameRichard Smith2016-02-092-0/+167
| | | | | | | | | that type from the global scope. Patch by Sterling Augustine, derived (with permission) from code from Cling by Vassil Vassilev and Philippe Canal. llvm-svn: 260278
* Make ParentMap work with explicit specializations of function templates.Nico Weber2016-02-081-0/+7
| | | | | | | | | | | | | | | | | For an explicit specialization, we first build a FunctionDecl, and then we call SubstDecl() on it to build a second FunctionDecl, which has the first FunctionDecl as canonical decl. The address of an explicit specialization of function template used to be the canonical decl of the FunctionDecl. This is different from all the other DeduceTemplateArguments() calls in SemaOverload, and since the canonical decl isn't visited by ParentMap while the redecl is, it also made ParentMap assert when computing the parent of a address-of-explicit-specialization-fun-template. To fix, remove the getCanonicalDecl() call. No behavior difference for clang, but it fixes an assert in ParentMap (which is e.g. used by libTooling). llvm-svn: 260159
* clang-format: Fix weird alignment when not aligning after brackets.Daniel Jasper2016-02-081-0/+5
| | | | | | | | | | | | | | | | Before: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); After: bbbbbbbbbbbb(aaaaaaaaaaaaaaaaaaaaaaaa, // ccccccc(aaaaaaaaaaaaaaaaa, // b)); This fixes llvm.org/PR24905. llvm-svn: 260080
* clang-format: [JS] Don't count shortened object literals as blocks.Daniel Jasper2016-02-071-0/+5
| | | | | | | | | | | | | | | Before: f({a}, () => { g(); // }); After: f({a}, () => { g(); // }); llvm-svn: 260060
* [ASTMatchers] Allow hasName() to look through inline namespacesSamuel Benzaquen2016-02-051-0/+46
| | | | | | | | | | | | | | | | | Summary: Allow hasName() to look through inline namespaces. This will fix the interaction between some clang-tidy checks and libc++. libc++ defines names in an inline namespace named std::<version_#>. When we try to match a name using hasName("std::xxx") it fails to match and the clang-tidy check does not work. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D15506 llvm-svn: 259898
* clang-format: Fix corner case in template detection.Daniel Jasper2016-02-051-0/+4
| | | | | | | | | | Before: f(a.operator() < A > ()); After: f(a.operator()<A>()); llvm-svn: 259884
OpenPOWER on IntegriCloud