summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
* Handle constructors and destructors a bit more uniformly in CodeGen.Rafael Espindola2014-09-089-173/+161
| | | | | | | | | There were code paths that are duplicated for constructors and destructors just because we have both CXXCtorType and CXXDtorsTypes. This patch introduces an unified enum and reduces code deplication a bit. llvm-svn: 217383
* Add __builtin_assume and __builtin_assume_aligned using @llvm.assume.Hal Finkel2014-09-076-5/+101
| | | | | | | | | | | This makes use of the recently-added @llvm.assume intrinsic to implement a __builtin_assume(bool) intrinsic (to provide additional information to the optimizer). This hooks up __assume in MS-compatibility mode to mirror __builtin_assume (the semantics have been intentionally kept compatible), and implements GCC's __builtin_assume_aligned as assume((p - o) & mask == 0). LLVM now contains special logic to deal with assumptions of this form. llvm-svn: 217349
* MS format strings: parse the 'Z' printf conversion specifier (PR20808)Hans Wennborg2014-09-072-2/+13
| | | | llvm-svn: 217326
* Add error, recovery and fixit for "~A::A() {...}".Richard Smith2014-09-061-2/+21
| | | | llvm-svn: 217302
* Add -Wunused-local-typedef, a warning that finds unused local typedefs.Nico Weber2014-09-0610-6/+143
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning warns on TypedefNameDecls -- typedefs and C++11 using aliases -- that are !isReferenced(). Since the isReferenced() bit on TypedefNameDecls wasn't used for anything before this warning it wasn't always set correctly, so this patch also adds a few missing MarkAnyDeclReferenced() calls in various places for TypedefNameDecls. This is made a bit complicated due to local typedefs possibly being used only after their local scope has closed. Consider: template <class T> void template_fun(T t) { typename T::Foo s3foo; // YYY (void)s3foo; } void template_fun_user() { struct Local { typedef int Foo; // XXX } p; template_fun(p); } Here the typedef in XXX is only used at end-of-translation unit, when YYY in template_fun() gets instantiated. To handle this, typedefs that are unused when their scope exits are added to a set of potentially unused typedefs, and that set gets checked at end-of-TU. Typedefs that are still unused at that point then get warned on. There's also serialization code for this set, so that the warning works with precompiled headers and modules. For modules, the warning is emitted when the module is built, for precompiled headers each time the header gets used. Finally, consider a function using C++14 auto return types to return a local type defined in a header: auto f() { struct S { typedef int a; }; return S(); } Here, the typedef escapes its local scope and could be used by only some translation units including the header. To not warn on this, add a RecursiveASTVisitor that marks all delcs on local types returned from auto functions as referenced. (Except if it's a function with internal linkage, or the decls are private and the local type has no friends -- in these cases, it _is_ safe to warn.) Several of the included testcases (most of the interesting ones) were provided by Richard Smith. (gcc's spelling -Wunused-local-typedefs is supported as an alias for this warning.) llvm-svn: 217298
* Move the initialization of VAListTagName after InitializeSema()Ben Langmuir2014-09-051-2/+4
| | | | | | | | | | | | | | | | | | | | This innocuous statement to get the identifier info for __va_list_tag was causing an assertion failure: NextIsPrevious() && "decl became non-canonical unexpectedly" if the __va_list_tag identifier was found in a PCH in some circumstances, because it was looked up before the ASTReader had a Sema object to use to find existing decls to merge with. We could possibly move getting the identifier info even later, or make it lazy if we wanted to, but this seemed like the minimal change. Now why a PCH would have this identifier in the first place is a bit mysterious. This seems to be related to the global module index in some way, because when the test case is built without the global module index it will not emit an identifier for __va_list_tag into the PCH, but with the global module index it does. llvm-svn: 217275
* Separate the matchers by type and statically dispatch to the right list.Samuel Benzaquen2014-09-051-40/+72
| | | | | | | | | | | | | | | | | Summary: Separate the matchers by type and statically dispatch to the right list. For any node type that we support, it reduces the number of matchers we run it through. For node types we do not support, it makes match() a noop. This change improves our clang-tidy related benchmark by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5197 llvm-svn: 217274
* -frewrite-includes: Normalize line endings to match the main source fileReid Kleckner2014-09-051-52/+90
| | | | | | | | | | | | | | | | | | | | | | It is very common to include headers with DOS-style line endings, such as windows.h, from source files with Unix-style line endings. Previously, we would end up with mixed line endings and #endifs that appeared to be on the same line: #if 0 /* expanded by -frewrite-includes */ #include <windows.h>^M#endif /* expanded by -frewrite-includes */ Clang treats either of \r or \n as a line ending character, so this is purely a cosmetic issue. This has no automated test because most Unix tools on Windows will implictly convert CRLF to LF when reading files, making it very hard to detect line ending mismatches. FileCheck doesn't understand {{\r}} either. Fixes PR20552. llvm-svn: 217259
* [analyzer] Don't crash if malloc() has an unexpected function prototype.Jordan Rose2014-09-051-4/+4
| | | | | | Patch by Daniel Fahlgren! llvm-svn: 217258
* [ARMv8] Add support for 32-bit MIN/MAXNM and directed rounding.James Molloy2014-09-051-0/+16
| | | | | | | | This patch adds support for the 32bit numeric max/min and directed round-to-integral NEON intrinsics that were added as part of v8, along with unit tests. Patch by Graham Hunter! llvm-svn: 217242
* clang-format: [JS] Format embedded function literals more efficently.Daniel Jasper2014-09-051-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Before: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; After: return { a: a, link: function() { f(); // }, link: function() { f(); // } }; llvm-svn: 217238
* clang-format: [JS] JavaScript does not have the */&/&& madness.Daniel Jasper2014-09-051-0/+3
| | | | | | | | | | | | | Before: e&& e.SomeFunction(); After: e && e.SomeFunction(); Yeah, this might be useful for C++, too, but it is not such a frequent pattern there (plus the fix is much harder). llvm-svn: 217237
* clang-format: [JS] Better support for empty function literals.Daniel Jasper2014-09-051-0/+7
| | | | | | | | | | Before: SomeFunction(function(){}); After: SomeFunction(function() {}); llvm-svn: 217236
* clang-format: [JS] Fix indentation in dict literals.Daniel Jasper2014-09-051-2/+6
| | | | | | | | | | | | | | | | | | Before: return { 'finish': // a }; After: return { 'finish': // a }; llvm-svn: 217235
* unique_ptrify AnalysisConsumer.cpp::CreateUbiVizDavid Blaikie2014-09-051-4/+4
| | | | llvm-svn: 217212
* Remove a use of raw pointer ownership (then non-ownership) in ↵David Blaikie2014-09-051-2/+3
| | | | | | | | | TrimmedGraph::popNextReportGraph (just cleaning up unique_ptr stuff by finding interesting 'reset' calls at the moment) llvm-svn: 217210
* unique_ptrify ExplodedGraph::trimDavid Blaikie2014-09-052-4/+4
| | | | llvm-svn: 217208
* unique_ptrify the result of ConstraintManagerCreator and StoreManagerCreatorDavid Blaikie2014-09-043-8/+9
| | | | llvm-svn: 217206
* unique_ptrify BugReporter::visitorsDavid Blaikie2014-09-047-91/+71
| | | | llvm-svn: 217205
* Stop double visiting some expressions during self reference checking.Richard Trieu2014-09-041-5/+17
| | | | | | | | Originally, self reference checking made a double pass over some expressions to handle reference type checking. Now, allow HandleValue to also check reference types, and fallback to Visit for unhandled expressions. llvm-svn: 217203
* Don't allow inline asm statements to reference parameters in naked functionsHans Wennborg2014-09-041-0/+13
| | | | | | Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217200
* Don't allow non-ASM statements in naked functionsHans Wennborg2014-09-041-0/+11
| | | | | | | | | | Naked functions don't have prologues or epilogues, so doing codegen for anything other than inline assembly would be completely hit or miss. Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217199
* Don't emit prologues or epilogues for naked functions (PR18791, PR20028)Hans Wennborg2014-09-041-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | For naked functions with parameters, Clang would still emit stores in the prologue that would clobber the stack, because LLVM doesn't set up a stack frame. (This shows up in -O0 compiles, because the stores are optimized away otherwise.) For example: __attribute__((naked)) int f(int x) { asm("movl $42, %eax"); asm("retl"); } Would result in: _Z1fi: movl 12(%esp), %eax movl %eax, (%esp) <--- Oops. movl $42, %eax retl Differential Revision: http://reviews.llvm.org/D5183 llvm-svn: 217198
* PR20844: If we fail to list-initialize a reference, map to the referenced typeRichard Smith2014-09-041-0/+13
| | | | | | | | | before retrying the initialization to produce diagnostics. Otherwise, we may fail to produce any diagnostics, and silently produce invalid AST in a -Asserts build. Also add a note to this codepath to make it more clear why we were trying to create a temporary. llvm-svn: 217197
* MS format strings: allow the 'h' length modifier with C, C, s and S (PR20808)Hans Wennborg2014-09-043-2/+30
| | | | llvm-svn: 217196
* MS format strings: support the 'w' length modifier (PR20808)Hans Wennborg2014-09-043-0/+26
| | | | llvm-svn: 217195
* MS inline asm: Allow __asm blocks to set a return valueReid Kleckner2014-09-045-5/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | If control falls off the end of a function after an __asm block, MSVC assumes that the inline assembly filled the EAX and possibly EDX registers with an appropriate return value. This functionality is used in inline functions returning 64-bit integers in system headers, so we need some amount of compatibility. This is implemented in Clang by adding extra output constraints to every inline asm block, and storing the resulting output registers into the return value slot. If we see an asm block somewhere in the function body, we emit a normal epilogue instead of marking the end of the function with a return type unreachable. Normal returns in functions not using this functionality will overwrite the return value slot, and in most cases LLVM should be able to eliminate the dead stores. Fixes PR17201. Reviewed By: majnemer Differential Revision: http://reviews.llvm.org/D5177 llvm-svn: 217187
* clang-format: [JS] Support alternative operator names as identifiers.Daniel Jasper2014-09-041-7/+8
| | | | | | | | | | Before: not. and . or . not_eq = 1; After: not.and.or.not_eq = 1; llvm-svn: 217179
* Win64: Add the uwtable attribute by default on Win64Reid Kleckner2014-09-041-5/+4
| | | | | | | Now that LLVM emits correct .pdata and .xdata for inline functions, we can reenable this. llvm-svn: 217178
* unique_ptrify JobList::JobsDavid Blaikie2014-09-046-69/+65
| | | | llvm-svn: 217168
* Fix double full-stop that was accidentally added in r217160.Daniel Sanders2014-09-041-1/+1
| | | | llvm-svn: 217161
* [mips] Mark aggregates returned in registers with the 'inreg' attribute.Daniel Sanders2014-09-041-6/+9
| | | | | | | | | | | | | | | | | | Summary: This allows us to easily find them in the backend after the aggregates have been lowered to other types. This is important on big-endian targets using the N32/N64 ABI's since these ABI's must shift small structures into the upper bits of the register. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D5005 llvm-svn: 217160
* clang-format: [JS] Supprot "catch" as function name.Daniel Jasper2014-09-041-1/+3
| | | | | | | | | | Before: someObject.catch (); After: someObject.catch(); llvm-svn: 217158
* clang-format: [JS] Support comments in dict literals.Daniel Jasper2014-09-041-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | Before: var stuff = { // comment for update update : false, // comment for update modules : false, // comment for update tasks : false }; After: var stuff = { // comment for update update : false, // comment for update modules : false, // comment for update tasks : false }; llvm-svn: 217157
* Refactor VariantMatcher::MatcherOps to reduce the amount of generated code.Samuel Benzaquen2014-09-042-7/+48
| | | | | | | | | | | | | | | | | | Summary: Refactor VariantMatcher::MatcherOps to reduce the amount of generated code. - Make some code type agnostic and move it to the cpp file. - Return a DynTypedMatcher instead of storing the object in MatcherOps. This change reduces the number of symbols generated in Registry.cpp by ~19%, the object byte size by ~17% and the compilation time (in non-release mode) by ~20%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5124 llvm-svn: 217152
* [mips] Zero-sized structs cannot be ignored in ↵Daniel Sanders2014-09-041-1/+6
| | | | | | | | | | | | | | | | | | | | | | | MipsABIInfo::classifyReturnType() for O32 Summary: They are returned indirectly which causes the other arguments to move to the next argument slot. With this, utils/ABITest does not discover any failing cases in the first 500 attempts on big/little endian for O32. Previously some of these failed. Also tested N32/N64 little endian (big endian has other known issues) with no issues. Reviewers: atanasyan Reviewed By: atanasyan Subscribers: atanasyan, cfe-commits Differential Revision: http://reviews.llvm.org/D4811 llvm-svn: 217147
* ARM: Default to apcs-gnu ABI for NetBSDOliver Stannard2014-09-041-1/+6
| | | | | | | | r216662 changed the default ABI for 32-bit ARM targets to be "aapcs" when no environment is given in the triple, however NetBSD requires it to be "apcs-gnu". llvm-svn: 217141
* [modules] Make NamespaceAliasDecl redeclarable, as it should be. This fixesRichard Smith2014-09-035-42/+68
| | | | | | | merging of namespace aliases across modules and improves source fidelity. Incidentally also fixes PR20816. llvm-svn: 217103
* Fix member function call on null pointer in Sema::FindInstantiatedDecl.Alexey Samsonov2014-09-031-11/+11
| | | | | | This bug was reported by UBSan. llvm-svn: 217059
* Update for LLVM api change.Rafael Espindola2014-09-031-1/+1
| | | | llvm-svn: 217050
* Split off CUDA-specific Sema parts to a new fileEli Bendersky2014-09-034-57/+77
| | | | | | | | | | | In line with SemaOpenMP.cpp, etc. CUDA-specific semantic analysis code goes into a separate file. This is in anticipation of adding extra functionality here in the near future. No change in functionality. Review: http://reviews.llvm.org/D5160 llvm-svn: 217043
* CGBuiltin: Use @llvm.fabs rather than fabs libcall when emitting builtinsTom Stellard2014-09-031-19/+5
| | | | | | | | | | | Using the intrinsic allows the SelectionDAGBuilder to turn this call into the FABS Node and also the intrinsic is something the vectorizer knows how to vectorize. This patch also sets the readnone attribute on this call, which should enable additional optmizations. llvm-svn: 217042
* ASTMatchers: Add a matcher to detect whether a decl or stmt is inside a ↵Benjamin Kramer2014-09-031-0/+2
| | | | | | | | | | | template instantiation. This is hoisted from clang-tidy where it's used everywhere. The implementation is not particularly efficient right now, but there is no easy fix for that. Differential Revision: http://reviews.llvm.org/D5085 llvm-svn: 217029
* Parse: Replace polymorphic functor objects with lambdas and llvm::function_ref.Benjamin Kramer2014-09-033-125/+63
| | | | | | No change in functionality. llvm-svn: 217025
* clang-format: Add an option 'SpaceAfterCStyleCast'.Daniel Jasper2014-09-032-2/+5
| | | | | | | | | | | | | | | | | This permits to add a space after closing parenthesis of a C-style cast. Defaults to false to preserve old behavior. Fixes llvm.org/PR19982. Before: (int)i; After: (int) i; Patch by Marek Kurdej. llvm-svn: 217022
* Allow a scoped lockable object to acquire/release multiple locks.Ed Schouten2014-09-031-125/+162
| | | | | | | | | | | | | | | | | Scoped lockable objects (mutex guards) are implemented as if it is a lock itself that is acquired upon construction and unlocked upon destruction. As it if course needs to be used to actually lock down something else (a mutex), it keeps track of this knowledge through its underlying mutex field in its FactEntry. The problem with this approach is that this only allows us to lock down a single mutex, so extend the code to use a vector of underlying mutexes. This, however, makes the code a bit more complex than necessary, so subclass FactEntry into LockableFactEntry and ScopedLockableFactEntry and move all the logic that differs between regular locks and scoped lockables into member functions. llvm-svn: 217016
* [modules] Use DeclContext::equals rather than == on DeclContext* whenRichard Smith2014-09-031-0/+5
| | | | | | | | | | determining whether a declaration is out of line, instead of assuming that the semantic and lexical DeclContext will be the same declaration whenever they're the same entity. This fixes behavior of declarations within merged classes and enums. llvm-svn: 217008
* Fix up formatting.Eli Bendersky2014-09-021-1/+1
| | | | llvm-svn: 216976
* Don't indent inside a namespace.Rafael Espindola2014-09-021-28/+28
| | | | llvm-svn: 216937
* Don't allow lambdas to capture invalid decls during template instantiations.Richard Trieu2014-09-021-1/+1
| | | | | | Fixes PR20731. llvm-svn: 216936
OpenPOWER on IntegriCloud