summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* [c++17] P0135R1: Guaranteed copy elision.Richard Smith2016-12-062-4/+28
| | | | | | | | When an object of class type is initialized from a prvalue of the same type (ignoring cv qualifications), use the prvalue to initialize the object directly instead of inserting a redundant elidable call to a copy constructor. llvm-svn: 288866
* [MS ABI] Implement more of the Itanium mangling rulesDavid Majnemer2016-12-061-21/+52
| | | | | | | | | | | | We didn't implement handle corner cases like: - lambdas used to initialize a field - lambdas in default argument initializers This fixes PR31197. Differential Revision: https://reviews.llvm.org/D27226 llvm-svn: 288826
* Fix two clang-tidy misc-move-forwarding-reference warningsMalcolm Parsons2016-12-061-1/+1
| | | | | | Patch by Michael Sharpe. llvm-svn: 288813
* DR1213: element access on an array xvalue or prvalue produces an xvalue. In theRichard Smith2016-12-052-8/+16
| | | | | | | | | | | | | | latter case, a temporary array object is materialized, and can be lifetime-extended by binding a reference to the member access. Likewise, in an array-to-pointer decay, an rvalue array is materialized before being converted into a pointer. This caused IR generation to stop treating file-scope array compound literals as having static storage duration in some cases in C++; that has been rectified by modeling such a compound literal as an lvalue. This also improves clang's compatibility with GCC for those cases. llvm-svn: 288654
* [Sema] Don't perform aggregate initialization for types with explicit ↵Eric Fiselier2016-12-031-15/+16
| | | | | | | | | | | | | | | | constructors Summary: The C++17 rules for aggregate initialization changed to disallow types with explicit constructors [dcl.init.aggr]p1. This patch implements that new rule. Reviewers: rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D25654 llvm-svn: 288565
* Delete tautological assertion.Jonathan Roelofs2016-12-021-1/+0
| | | | | | | | After r256463, both the LHS and RHS now refer to the same variable. Before, they referred to the member, the parameter respectively. Now GCC6's -Wtautological-compare complains. llvm-svn: 288444
* [OpenCL] Refactor read_only/write_only pipes.Joey Gouly2016-12-011-45/+15
| | | | | | | | | | | This adds the access qualifier to the Pipe Type, rather than using a class hierarchy. It also fixes mergeTypes for Pipes, by disallowing merges. Only identical pipe types can be merged. The test case in invalid-pipes-cl2.0.cl is added to check that. llvm-svn: 288332
* [OpenMP] Sema and parsing for 'teams distribute parallel for simd' pragmaKelvin Li2016-11-303-0/+70
| | | | | | | | This patch is to implement sema and parsing for 'teams distribute parallel for simd' pragma. Differential Revision: https://reviews.llvm.org/D27084 llvm-svn: 288294
* getObjCEncodingForMethodDecl cannot fail. Simplify. NFC.John McCall2016-11-291-13/+15
| | | | llvm-svn: 288203
* Support constant expression evaluation for wchar_t versions of simple stringRichard Smith2016-11-292-30/+76
| | | | | | functions, in order to support constexpr std::char_traits<wchar_t>. llvm-svn: 288193
* Correct comment: we are creating a canonicla decltypetype.Yaron Keren2016-11-291-1/+1
| | | | llvm-svn: 288124
* [ASTDumper] Add some more character escapes for convenience.Benjamin Kramer2016-11-241-2/+5
| | | | llvm-svn: 287859
* Remove C++ default arg side table for MS ABI ctor closuresReid Kleckner2016-11-234-38/+0
| | | | | | | | | | | | | | | | | | | Summary: We don't need a side table in ASTContext to hold CXXDefaultArgExprs. The important part of building the CXXDefaultArgExprs was to ODR use the default argument expressions, not to make AST nodes. Refactor the code to only check the default argument, and remove the side table in ASTContext which wasn't being serialized. Fixes PR31121 Reviewers: thakis, rsmith, majnemer Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27007 llvm-svn: 287774
* [ASTImporter] Added ability to import AtomicType nodesGabor Horvath2016-11-231-0/+9
| | | | | | | | Patch by: Kareem Khazem Differential Revision: https://reviews.llvm.org/D26328 llvm-svn: 287763
* Indicate in AST dump whether special member functions are defaulted and trivial.Richard Smith2016-11-211-1/+8
| | | | llvm-svn: 287599
* [ObjC] Prevent infinite loops when iterating over redeclarationAlex Lorenz2016-11-211-0/+6
| | | | | | | | | | | | | | | | of a method that was declared in an invalid interface This commit fixes an infinite loop that occurs when clang tries to iterate over redeclaration of a method that was declared in an invalid @interface. The existing validity checks don't catch this as that @interface is a duplicate of a previously declared valid @interface declaration, so we have to verify that the found redeclaration is in a valid declaration context. rdar://29220965 Differential Revision: https://reviews.llvm.org/D26664 llvm-svn: 287530
* [OpenCL] Introduce ReadPipeType and WritePipeType.Joey Gouly2016-11-182-10/+39
| | | | | | | This allows Sema to diagnose passing a read_only pipe to a write_only pipe argument. llvm-svn: 287343
* ObjC Module: try to make objc module deterministic.Manman Ren2016-11-171-2/+8
| | | | | | | Make sure that comparing selectors in DeclarationName does its job. rdar://problem/28988750 llvm-svn: 287244
* Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini2016-11-161-12/+13
| | | | | | | | | | | | | | Objective-C Blocks Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Recommit r287039 (that was reverted in r287039) with a tweak to be more generic, and test fixes! Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287085
* Outline evaluation of calls to builtins to avoid inflating stack usage for theRichard Smith2016-11-161-1/+19
| | | | | | | common case of a call to a non-builtin, particularly for unoptimized ASan builds (where the per-variable stack usage can be quite high). llvm-svn: 287066
* Revert "Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini2016-11-151-12/+11
| | | | | | | | Objective-C Blocks" This reverts commit r287039, tests are broken. llvm-svn: 287043
* Improve handling of __FUNCTION__ and other predefined expression for ↵Mehdi Amini2016-11-151-11/+12
| | | | | | | | | | | Objective-C Blocks Instead of always displaying the mangled name, try to do better and get something closer to regular functions. Differential Revision: https://reviews.llvm.org/D26522 llvm-svn: 287039
* Fix PR28366: Handle variables from enclosing local scopes more gracefully ↵Faisal Vali2016-11-131-2/+13
| | | | | | | | | | | | | | | | | | during constant expression evaluation. Only look for a variable's value in the constant expression evaluation activation frame, if the variable was indeed declared in that frame, otherwise it might be a constant expression and be usable within a nested local scope or emit an error. void f(char c) { struct X { static constexpr char f() { return c; // error gracefully here as opposed to crashing. } }; int I = X::f(); } llvm-svn: 286748
* [c++1z] Support constant folding for __builtin_strchr and __builtin_memchr.Richard Smith2016-11-121-3/+62
| | | | llvm-svn: 286699
* [c++1z] Add constant-folding support for strcmp, strncmp, and memcmp, toRichard Smith2016-11-111-0/+50
| | | | | | support constexpr char_traits. llvm-svn: 286678
* When a DecompositionDecl is marked invalid, also set the child BindingDecl's toRichard Trieu2016-11-111-1/+13
| | | | | | invalid. llvm-svn: 286630
* Accept nullability qualifiers on array parameters.Jordan Rose2016-11-101-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since array parameters decay to pointers, '_Nullable' and friends should be available for use there as well. This is especially important for parameters that are typedefs of arrays. The unsugared syntax for this follows the syntax for 'static'-sized arrays in C: void test(int values[_Nullable]); This syntax was previously accepted but the '_Nullable' (and any other attributes) were silently discarded. However, applying '_Nullable' to a typedef was previously rejected and is now accepted; therefore, it may be necessary to test for the presence of this feature: #if __has_feature(nullability_on_arrays) One important change here is that DecayedTypes don't always immediately contain PointerTypes anymore; they may contain an AttributedType instead. This only affected one place in-tree, so I would guess it's not likely to cause problems elsewhere. This commit does not change -Wnullability-completeness just yet. I want to think about whether it's worth doing something special to avoid breaking existing clients that compile with -Werror. It also doesn't change '#pragma clang assume_nonnull' behavior, which currently treats the following two declarations as equivalent: #pragma clang assume_nonnull begin void test(void *pointers[]); #pragma clang assume_nonnull end void test(void * _Nonnull pointers[]); This is not the desired behavior, but changing it would break backwards-compatibility. Most likely the best answer is going to be adding a new warning. Part of rdar://problem/25846421 llvm-svn: 286519
* Make output of -ast-print a valid C++ code.Serge Pavlov2016-11-101-63/+158
| | | | | | | | | | | | | | | | | | Output generated by option -ast-print looks like C/C++ code, and it really is for plain C. For C++ the produced output was not valid C++ code, but the differences were small. With this change the output is fixed and can be compiled. Tests are changed so that output produced by -ast-print is compiled again with the same flags and both outputs are compared. Option -ast-print is extensively used in clang tests but it itself was tested poorly, existing tests only checked that compiler did not crash. There are unit tests in file DeclPrinterTest.cpp, but they test only terse output mode. Differential Revision: https://reviews.llvm.org/D26452 llvm-svn: 286439
* [AST] Dump dependent scope member expression with its member nameAlex Lorenz2016-11-091-0/+7
| | | | llvm-svn: 286365
* When the ASTImporter imports a source location, it avoids importing macroSean Callanan2016-11-071-2/+2
| | | | | | | | | | | | | | | | | expansions by calling getSpellingLoc(). That's great in most cases, but for macros defined in the '<built-in>' source file, the source file is invalid and does not import correctly, causing an assertion failure (the assertion is Invalid SLocOffset or bad function choice). A more reliable way to avoid this is to use getFileLoc(), which does not return built-in locations. This avoids the crash but still preserves valid source locations. I've added a testcase that covers the previously crashing scenario. https://reviews.llvm.org/D26054 llvm-svn: 286144
* Add some more asserts to clearly indicate that there are special casesChandler Carruth2016-11-041-0/+1
| | | | | | | | | | | | | | | | | which guarantee pointers are not null. These all seem to have useful properties and correlations to document, in one case we even had it in a comment but now it will also be an assert. This should prevent PVS-Studio from incorrectly claiming that there are a bunch of potential bugs here. But I feel really strongly that the PVS-Studio warnings that pointed at this code have a far too high false-positive rate to be entirely useful. These are just places where there did seem to be a useful invariant to document and verify with an assert. Several other places in the code were already correct and already have perfectly clear code documenting and validating their invariants, but still ran afoul of PVS-Studio. llvm-svn: 285985
* Do not print enum underlying type if language is not C++11Serge Pavlov2016-11-041-1/+1
| | | | | | | Output generated by option '-ast-print' must not contains enum base type specifications if source language does not include C++11. llvm-svn: 285979
* Improve obvious-most-derived-type devirtualization:Richard Smith2016-11-031-2/+26
| | | | | | | | | | | | | | * if the base is produced by a series of derived-to-base conversions, check the expression inside them when looking for an expression with a known dynamic type * step past MaterializeTemporaryExprs when checking for a known dynamic type * when checking for a known dynamic type, treat all class prvalues as having a known dynamic type after skipping all relevant rvalue subobject adjustments * treat callees formed by pointer-to-member access for a non-reference member type like callees formed by member access. llvm-svn: 285954
* Update manglings for C++17 noexcept function types to match Jason Merrill'sRichard Smith2016-11-031-3/+3
| | | | | | proposal on cxx-abi-dev earlier today. llvm-svn: 285870
* Teach clang-query to dump types. I couldn't find any existing tests for ↵Richard Smith2016-11-022-3/+11
| | | | | | clang-query's dumping functionality. =( llvm-svn: 285869
* regcall: Implement regcall Calling Conv in clangErich Keane2016-11-026-1/+32
| | | | | | | | | | This patch implements the register call calling convention, which ensures as many values as possible are passed in registers. CodeGen changes were committed in https://reviews.llvm.org/rL284108. Differential Revision: https://reviews.llvm.org/D25204 llvm-svn: 285849
* Add a note that points to the linkage specifier for the C++ linkage errorsAlex Lorenz2016-11-021-0/+12
| | | | | | | | | | | | This commit improves the "must have C++ linkage" error diagnostics that are emitted for C++ declarations like templates and literal operators by adding an additional note that points to the appropriate extern "C" linkage specifier. rdar://19021120 Differential Revision: https://reviews.llvm.org/D26189 llvm-svn: 285823
* Fix parenthesized assert (nfc).Manuel Klimek2016-11-011-2/+2
| | | | llvm-svn: 285685
* [x86][inline-asm] Add support for curly brackets escape using "%" in ↵Michael Zuckerman2016-10-311-7/+9
| | | | | | | | | | | | | | | | | extended inline asm. Commit on behalf of mharoush After LGTM and check all: This patch is a compatibility fix for clang, matching GCC support for charter escape when using extended in-line assembly (i.e, "%{" ,"%}" --> "{" ,"}" ). It is meant to enable support for advanced features such as AVX512 conditional\masked vector instructions/broadcast assembly syntax. Reviewer: 1. rnk Differential Revision: https://reviews.llvm.org/D25012 llvm-svn: 285585
* Make output of ast-print closer to C++ codeSerge Pavlov2016-10-311-4/+3
| | | | | | | Put semicolon after non-defining method declaration and a class specialization body. llvm-svn: 285543
* PR30831: Teach template type diffing to cope with TemplateSpecializationTypesRichard Smith2016-10-281-7/+10
| | | | | | that desugar to non-TSTs (such as injected-class-names). llvm-svn: 285437
* Fix implementation of the likely resolution of core issue 253 to support classRichard Smith2016-10-281-1/+1
| | | | | | | | based arrays. Patch by Ian Tessier! Differential Review: https://reviews.llvm.org/D25974 llvm-svn: 285430
* Relax assertion in ↵Justin Lebar2016-10-281-1/+1
| | | | | | | | | | FunctionDecl::doesDeclarationForceExternallyVisibleDefinition. Previously we were asserting that this declaration doesn't have a body *and* won't have a body after we continue parsing. This is too strong and breaks the go-bindings test during codegen. llvm-svn: 285412
* [CUDA] [AST] Allow isInlineDefinitionExternallyVisible to be called on ↵Justin Lebar2016-10-281-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | functions without bodies. Summary: In CUDA compilation, we call isInlineDefinitionExternallyVisible (via getGVALinkageForFunction) on functions while parsing their definitions. At the point in time when we call getGVALinkageForFunction, we haven't yet added the body to the function, so we trip this assert. But as far as I can tell, this is harmless. To work around this, we add a new flag to FunctionDecl, "WillHaveBody". There was other code that was working around the existing assert with a really awful hack -- this change lets us get rid of that hack. Reviewers: rsmith, tra Subscribers: aemerson, cfe-commits Differential Revision: https://reviews.llvm.org/D25640 llvm-svn: 285410
* Refactor call emission to package the function pointer together withJohn McCall2016-10-261-5/+9
| | | | | | | | | | | abstract information about the callee. NFC. The goal here is to make it easier to recognize indirect calls and trigger additional logic in certain cases. That logic will come in a later patch; in the meantime, I felt that this was a significant improvement to the code. llvm-svn: 285258
* Fix use-after-scope in ASTContext.Benjamin Kramer2016-10-261-1/+1
| | | | | | | | | | | | Extend lifetime of ExceptionTypeStorage, as it is referenced by CanonicalEPI and used outside the block (ExceptionSpec.Exceptions is an ArrayRef) Patch by Sam McCall! Differential Revision: https://reviews.llvm.org/D25983 llvm-svn: 285192
* Implement name mangling proposal for exception specifications from ↵Richard Smith2016-10-263-3/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | cxx-abi-dev 2016-10-11. This has the following ABI impact: 1) Functions whose parameter or return types are non-throwing function pointer types have different manglings in c++1z mode from prior modes. This is necessary because c++1z permits overloading on the noexceptness of function pointer parameter types. A warning is issued for cases that will change manglings in c++1z mode. 2) Functions whose parameter or return types contain instantiation-dependent exception specifications change manglings in all modes. This is necessary to support overloading on / SFINAE in these exception specifications, which a careful reading of the standard indicates has essentially always been permitted. Note that, in order to be affected by these changes, the code in question must specify an exception specification on a function pointer/reference type that is written syntactically within the declaration of another function. Such declarations are very rare, and I have so far been unable to find any code that would be affected by this. (Note that such things will probably become more common in C++17, since it's a lot easier to get a noexcept function type as a function parameter / return type there.) This change does not affect the set of symbols produced by a build of clang, libc++, or libc++abi. llvm-svn: 285150
* Re-apply patch r279045.Kelvin Li2016-10-253-0/+64
| | | | llvm-svn: 285066
* Fix 'unknown documentation command' warning rangesErik Verbruggen2016-10-251-4/+6
| | | | | | | | | Warnings generated by -Wdocumentation-unknown-command did only have a start location, not a full source range. This resulted in only the "carret" being show in messages, and IDEs highlighting only the single initial character. llvm-svn: 285056
* Fix bug where one of the cases where we mangle a <bare-unresolved-name> failedRichard Smith2016-10-241-25/+31
| | | | | | | | to emit the <template-args> portion. Refactor so that mangleUnresolvedName actually emits the entire <unresolved-name>, so this mistake is harder to make again. llvm-svn: 285022
OpenPOWER on IntegriCloud