summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST
Commit message (Collapse)AuthorAgeFilesLines
...
* NFC: Move ColorScope to global scopeStephen Kelly2018-11-291-56/+58
| | | | llvm-svn: 347900
* NFC: Constify ShowColorsStephen Kelly2018-11-291-1/+1
| | | | llvm-svn: 347899
* Set MustBuildLookupTable on PrimaryContext in ExternalASTMergerRaphael Isemann2018-11-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: `MustBuildLookupTable` must always be called on a primary context as we otherwise trigger an assert, but we don't ensure that this will always happen in our code right now. This patch explicitly requests the primary context when doing this call as this shouldn't break anything (as calling `getPrimaryContext` on a context which is its own primary context is a no-op) but will catch these rare cases where we somehow operate on a declaration context that is not its own primary context. See also D54863. Reviewers: martong, a.sidorin, shafik Reviewed By: martong Subscribers: davide, rnkovacs, cfe-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D54898 llvm-svn: 347863
* Correct 'target' default behavior on redecl, allow forward declaration.Erich Keane2018-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Declarations without the attribute were disallowed because it would be ambiguous which 'target' it was supposed to be on. For example: void ___attribute__((target("v1"))) foo(); void foo(); // Redecl of above, or fwd decl of below? void ___attribute__((target("v2"))) foo(); However, a first declaration doesn't have that problem, and erroring prevents it from working in cases where the forward declaration is useful. Additionally, a forward declaration of target==default wouldn't properly cause multiversioning, so this patch fixes that. The patch was not split since the 'default' fix would require implementing the same check for that case, followed by undoing the same change for the fwd-decl implementation. Change-Id: I66f2c5bc2477bcd3f7544b9c16c83ece257077b0 llvm-svn: 347805
* Revert "[ASTImporter] Changed use of Import to Import_New in ASTImporter."Davide Italiano2018-11-281-373/+311
| | | | | | This broke the lldb bots. llvm-svn: 347794
* [NFC] Move MultIversioning::Type into Decl so that it can be used inErich Keane2018-11-281-0/+11
| | | | | | | CodeGen Change-Id: I32b14edca3501277e0e65672eafe3eea38c6f9ae llvm-svn: 347791
* Re-commit r347417 "Re-Reinstate 347294 with a fix for the failures."Hans Wennborg2018-11-283-54/+118
| | | | | | | This was reverted in r347656 due to me thinking it caused a miscompile of Chromium. Turns out it was the Chromium code that was broken. llvm-svn: 347756
* [ASTImporter] Changed use of Import to Import_New in ASTImporter.Balazs Keri2018-11-281-311/+373
| | | | | | | | | | | | Reviewers: a.sidorin, shafik, a_sidorin Reviewed By: a_sidorin Subscribers: gamesh411, a_sidorin, dkrupp, martong, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53818 llvm-svn: 347752
* PR39809: (const void*)0 is not a null pointer constant in C.Richard Smith2018-11-281-6/+6
| | | | llvm-svn: 347730
* [ASTImporter] Added Import functions for transition to new API.Balazs Keri2018-11-271-0/+94
| | | | | | | | | | | | | | | | | | | | | | | Summary: These Import_New functions should be used in the ASTImporter, and the old Import functions should not be used. Later the Import_New should be renamed to Import again and the old Import functions must be removed. But this can happen only after LLDB was updated to use the new Import interface. This commit is only about introducing the new Import_New functions. These are not implemented now, only calling the old Import ones. Reviewers: shafik, rsmith, a_sidorin, a.sidorin Reviewed By: a_sidorin Subscribers: spyffe, a_sidorin, gamesh411, shafik, rsmith, dkrupp, martong, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53751 llvm-svn: 347685
* Revert r347417 "Re-Reinstate 347294 with a fix for the failures."Hans Wennborg2018-11-273-118/+54
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused a miscompile in Chrome (see crbug.com/908372) that's illustrated by this small reduction: static bool f(int *a, int *b) { return !__builtin_constant_p(b - a) || (!(b - a)); } int arr[] = {1,2,3}; bool g() { return f(arr, arr + 3); } $ clang -O2 -S -emit-llvm a.cc -o - g() should return true, but after r347417 it became false for some reason. This also reverts the follow-up commits. r347417: > Re-Reinstate 347294 with a fix for the failures. > > Don't try to emit a scalar expression for a non-scalar argument to > __builtin_constant_p(). > > Third time's a charm! r347446: > The result of is.constant() is unsigned. r347480: > A __builtin_constant_p() returns 0 with a function type. r347512: > isEvaluatable() implies a constant context. > > Assume that we're in a constant context if we're asking if the expression can > be compiled into a constant initializer. This fixes the issue where a > __builtin_constant_p() in a compound literal was diagnosed as not being > constant, even though it's always possible to convert the builtin into a > constant. r347531: > A "constexpr" is evaluated in a constant context. Make sure this is reflected > if a __builtin_constant_p() is a part of a constexpr. llvm-svn: 347656
* [ASTImporter] Typedef import brings in the complete typeGabor Marton2018-11-271-2/+9
| | | | | | | | | | | | | | | | | | | | | Summary: When we already have an incomplete underlying type of a typedef in the "To" context, and the "From" context has the same typedef, but the underlying type is complete, then the imported type should be complete. Fixes an assertion in CTU analysis of Xerces: Assertion `DD && "queried property of class with no definition"' failed. This assert is happening in the analyzer engine, because that attempts to query an underlying type of a typedef, which happens to be incomplete. Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53693 llvm-svn: 347648
* [AArch64] Add aarch64_vector_pcs function attribute to ClangSander de Smalen2018-11-263-1/+7
| | | | | | | | | | | | | | | | | | | | This is the Clang patch to complement the following LLVM patches: https://reviews.llvm.org/D51477 https://reviews.llvm.org/D51479 More information describing the vector ABI and procedure call standard can be found here: https://developer.arm.com/products/software-development-tools/\ hpc/arm-compiler-for-hpc/vector-function-abi Patch by Kerry McLaughlin. Reviewed By: rjmccall Differential Revision: https://reviews.llvm.org/D54425 llvm-svn: 347571
* [ASTImporter][Structural Eq] Check for isBeingDefinedGabor Marton2018-11-262-3/+10
| | | | | | | | | | | | | | | | Summary: If one definition is currently being defined, we do not compare for equality and we assume that the decls are equal. Reviewers: a_sidorin, a.sidorin, shafik Reviewed By: a_sidorin Subscribers: gamesh411, shafik, rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53697 llvm-svn: 347564
* A "constexpr" is evaluated in a constant context. Make sure this is reflectedBill Wendling2018-11-261-0/+2
| | | | | | if a __builtin_constant_p() is a part of a constexpr. llvm-svn: 347531
* isEvaluatable() implies a constant context.Bill Wendling2018-11-241-2/+4
| | | | | | | | | | Assume that we're in a constant context if we're asking if the expression can be compiled into a constant initializer. This fixes the issue where a __builtin_constant_p() in a compound literal was diagnosed as not being constant, even though it's always possible to convert the builtin into a constant. llvm-svn: 347512
* Re-Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-213-52/+112
| | | | | | | | | Don't try to emit a scalar expression for a non-scalar argument to __builtin_constant_p(). Third time's a charm! llvm-svn: 347417
* Revert r347364 again, the fix was incomplete.Nico Weber2018-11-213-112/+52
| | | | llvm-svn: 347389
* Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-203-52/+112
| | | | | | | EvaluateAsInt() is sometimes called in a constant context. When that's the case, we need to specify it as so. llvm-svn: 347364
* [AST] Store the expressions in ParenListExpr in a trailing arrayBruno Ricci2018-11-202-15/+36
| | | | | | | | | | | | Use the newly available space in the bit-fields of Stmt and store the expressions in a trailing array. This saves 2 pointer per ParenListExpr. Differential Revision: https://reviews.llvm.org/D54675 Reviewed By: rjmccall llvm-svn: 347320
* Revert 347294, it turned many bots on lab.llvm.org:8011/console red.Nico Weber2018-11-203-74/+31
| | | | llvm-svn: 347314
* [ASTImporter] Set redecl chain of functions before any other importGabor Marton2018-11-201-19/+24
| | | | | | | | | | | | | | | | | | | Summary: FunctionDecl import starts with a lookup and then we create a new Decl. Then in case of CXXConstructorDecl we further import other Decls (base classes, members through CXXConstructorDecl::inits()) before connecting the redecl chain. During those in-between imports structural eq fails because the canonical decl is different. This commit fixes this. Synthesizing a test seemed extremely hard, however, Xerces analysis reproduces the problem. Reviewers: a_sidorin, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53702 llvm-svn: 347306
* Use is.constant intrinsic for __builtin_constant_pBill Wendling2018-11-203-31/+74
| | | | | | | | | | | | | | | | Summary: A __builtin_constant_p may end up with a constant after inlining. Use the is.constant intrinsic if it's a variable that's in a context where it may resolve to a constant, e.g., an argument to a function after inlining. Reviewers: rsmith, shafik Subscribers: jfb, kristina, cfe-commits, nickdesaulniers, jyknight Differential Revision: https://reviews.llvm.org/D54355 llvm-svn: 347294
* [AST][NFC] Pack CXXDefaultInitExprBruno Ricci2018-11-171-5/+6
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultInitExpr. llvm-svn: 347138
* [OpenCL] Enable address spaces for references in C++Anastasia Stulova2018-11-161-7/+12
| | | | | | | | | | | | | Added references to the addr spaces deduction and enabled CL2.0 features (program scope variables and storage class qualifiers) to work in C++ mode too. Fixed several address space conversion issues in CodeGen for references. Differential Revision: https://reviews.llvm.org/D53764 llvm-svn: 347059
* [AST] Store the string data in StringLiteral in a trailing array of charsBruno Ricci2018-11-151-65/+67
| | | | | | | | | | | | | | | | | | | | | | | | | Use the newly available space in the bit-fields of Stmt and store the string data in a trailing array of chars after the trailing array of SourceLocation. This cuts the size of StringLiteral by 2 pointers. Also refactor slightly StringLiteral::Create and StringLiteral::CreateEmpty so that StringLiteral::Create is just responsible for the allocation, and the constructor is responsible for doing all the initialization. This match what is done for the other classes in general. This patch should have no other functional changes apart from this. A concern was raised during review about the interaction between this patch and serialization abbreviations. I believe however that there is currently no abbreviation defined for StringLiteral. The only statements/expressions which have abbreviations are currently DeclRefExpr, IntegerLiteral, CharacterLiteral and ImplicitCastExpr. Differential Revision: https://reviews.llvm.org/D54166 Reviewed By: dblaikie, rjmccall llvm-svn: 346969
* [AST][NFC] Various NFCs in StringLiteralBruno Ricci2018-11-151-21/+21
| | | | | | | | | | | | | Factored out of D54166 ([AST] Store the string data in StringLiteral in a trailing array of chars): * For-range loops in containsNonAscii and containsNonAsciiOrNull. * Comments and style fixes. * int -> unsigned in mapCharByteWidth since TargetInfo::getCharWidth and friends return an unsigned, and StringLiteral manipulates and stores CharByteWidth as an unsigned. llvm-svn: 346967
* [AST] Pack MemberExprBruno Ricci2018-11-151-2/+3
| | | | | | | | | | | | Use the newly available space in the bit-fields of Stmt to store some data from MemberExpr. This saves one pointer per MemberExpr. Differential Revision: https://reviews.llvm.org/D54525 Reviewed By: dblaikie llvm-svn: 346953
* [AST] Fix typo in MicrosoftMangleShoaib Meenai2018-11-141-29/+29
| | | | | | | | Correct the spelling from Artifical to Artificial. Differential Revision: https://reviews.llvm.org/D54536 llvm-svn: 346882
* [AST] Allow limiting the scope of common AST traversals (getParents, RAV).Sam McCall2018-11-141-161/+168
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The goal is to allow analyses such as clang-tidy checks to run on a subset of the AST, e.g. "only on main-file decls" for interactive tools. Today, these become "problematically global" by running RecursiveASTVisitors rooted at the TUDecl, or by navigating up via ASTContext::getParent(). The scope is restricted using a set of top-level-decls that RecursiveASTVisitors should be rooted at. This also applies to the visitor that populates the parent map, and so the top-level-decls are considered to have no parents. This patch makes the traversal scope a mutable property of ASTContext. The more obvious way to do this is to pass the top-level decls to relevant functions directly, but this has some problems: - it's error-prone: accidentally mixing restricted and unrestricted scopes is a performance trap. Interleaving multiple analyses is common (many clang-tidy checks run matchers or RAVs from matcher callbacks) - it doesn't map well to the actual use cases, where we really do want *all* traversals to be restricted. - it involves a lot of plumbing in parts of the code that don't care about traversals. This approach was tried out in D54259 and D54261, I wanted to like it but it feels pretty awful in practice. Caveats: to get scope-limiting behavior of RecursiveASTVisitors, callers have to call the new TraverseAST(Ctx) function instead of TraverseDecl(TU). I think this is an improvement to the API regardless. Reviewers: klimek, ioeric Subscribers: mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D54309 llvm-svn: 346847
* OpenCL: Don't warn on v printf modifierMatt Arsenault2018-11-132-0/+12
| | | | | | | | | | | This avoids spurious warnings, but could use a lot of work. For example the number of vector elements is not verified, and the passed value type is not checked. Fixes bug 39486 llvm-svn: 346806
* [AST] Revert r346793 and r346781Bruno Ricci2018-11-131-2/+2
| | | | | | This somehow breaks the msan bots. Revert while I figure it out. llvm-svn: 346801
* [AST][NFC] Style fixes for UnaryOperatorBruno Ricci2018-11-131-2/+2
| | | | | | | | | In preparation for the patch which will move some data to the bit-fields of Stmt. In particular, rename the private variable "Val" -> "Operand" since the substatement is the operand of the unary operator. Run clang-format on UnaryOperator. NFC otherwise. llvm-svn: 346781
* [AST][NFC] Pack DeclRefExprBruno Ricci2018-11-131-1/+2
| | | | | | | Move the SourceLocation to the bit-fields of Stmt + clang-format. This saves one pointer per DeclRefExpr but otherwise NFC. llvm-svn: 346770
* PR39628 Treat all non-zero values as 'true' in bool compound-assignmentRichard Smith2018-11-121-2/+3
| | | | | | in constant evaluation, not just odd values. llvm-svn: 346699
* Pass the function type instead of the return type to FunctionDecl::CreateJonas Devlieghere2018-11-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix places where the return type of a FunctionDecl was being used in place of the function type FunctionDecl::Create() takes as its T parameter the type of function that should be created, not the return type. Passing in the return type looks to have been copypasta'd around a bit, but the number of correct usages outweighs the incorrect ones so I've opted for keeping what T is the same and fixing up the call sites instead. This fixes a crash in Clang when attempting to compile the following snippet of code with -fblocks -fsanitize=function -x objective-c++ (my original repro case): void g(void(^)()); void f() { __block int a = 0; g(^(){ a++; }); } as well as the following which only requires -fsanitize=function -x c++: void f(char * buf) { __builtin_os_log_format(buf, ""); } Patch by: Ben (bobsayshilol) Differential revision: https://reviews.llvm.org/D53263 llvm-svn: 346601
* Compound literals, enums, et al require const exprBill Wendling2018-11-093-0/+29
| | | | | | | | | | | | | | | | | | Summary: Compound literals, enums, file-scoped arrays, etc. require their initializers and size specifiers to be constant. Wrap the initializer expressions in a ConstantExpr so that we can easily check for this later on. Reviewers: rsmith, shafik Reviewed By: rsmith Subscribers: cfe-commits, jyknight, nickdesaulniers Differential Revision: https://reviews.llvm.org/D53921 llvm-svn: 346455
* [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extensionAndrew Savonichev2018-11-089-0/+44
| | | | | | | | | | | | | | | | | | Summary: Documentation can be found at https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt Patch by Kristina Bessonova Reviewers: Anastasia, yaxunl, shafik Reviewed By: Anastasia Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, cfe-commits Differential Revision: https://reviews.llvm.org/D51484 llvm-svn: 346392
* Revert r346326 [OpenCL] Add support of ↵Andrew Savonichev2018-11-079-44/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | cl_intel_device_side_avc_motion_estimation This patch breaks Index/opencl-types.cl LIT test: Script: -- : 'RUN: at line 1'; stage1/bin/c-index-test -test-print-type llvm/tools/clang/test/Index/opencl-types.cl -cl-std=CL2.0 | stage1/bin/FileCheck llvm/tools/clang/test/Index/opencl-types.cl -- Command Output (stderr): -- llvm/tools/clang/test/Index/opencl-types.cl:3:26: warning: unsupported OpenCL extension 'cl_khr_fp16' - ignoring [-Wignored-pragmas] llvm/tools/clang/test/Index/opencl-types.cl:4:26: warning: unsupported OpenCL extension 'cl_khr_fp64' - ignoring [-Wignored-pragmas] llvm/tools/clang/test/Index/opencl-types.cl:8:9: error: use of type 'double' requires cl_khr_fp64 extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:11:8: error: declaring variable of type 'half' is not allowed llvm/tools/clang/test/Index/opencl-types.cl:15:3: error: use of type 'double' requires cl_khr_fp64 extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:16:3: error: use of type 'double4' (vector of 4 'double' values) requires cl_khr_fp64 extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:26:26: warning: unsupported OpenCL extension 'cl_khr_gl_msaa_sharing' - ignoring [-Wignored-pragmas] llvm/tools/clang/test/Index/opencl-types.cl:35:44: error: use of type '__read_only image2d_msaa_t' requires cl_khr_gl_msaa_sharing extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:36:49: error: use of type '__read_only image2d_array_msaa_t' requires cl_khr_gl_msaa_sharing extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:37:49: error: use of type '__read_only image2d_msaa_depth_t' requires cl_khr_gl_msaa_sharing extension to be enabled llvm/tools/clang/test/Index/opencl-types.cl:38:54: error: use of type '__read_only image2d_array_msaa_depth_t' requires cl_khr_gl_msaa_sharing extension to be enabled llvm-svn: 346338
* [OpenCL] Add support of cl_intel_device_side_avc_motion_estimation extensionAndrew Savonichev2018-11-079-0/+44
| | | | | | | | | | | | | | | | | | Summary: Documentation can be found at https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_device_side_avc_motion_estimation.txt Patch by Kristina Bessonova Reviewers: Anastasia, yaxunl, shafik Reviewed By: Anastasia Subscribers: arphaman, sidorovd, AlexeySotkin, krisb, bader, asavonic, cfe-commits Differential Revision: https://reviews.llvm.org/D51484 llvm-svn: 346326
* os_log: Allow specifying mask type in format string.Akira Hatanaka2018-11-062-2/+17
| | | | | | | | | | A mask type is a 1 to 8-byte string that follows the "mask." annotation in the format string. This enables obfuscating data in the event the provided privacy level isn't enabled. rdar://problem/36756282 llvm-svn: 346211
* os_log: Add a new privacy annotation "sensitive".Akira Hatanaka2018-11-062-3/+13
| | | | | | | | | | This is a stricter privacy annotation than "private", which will be used for data that shouldn’t be logged to disk. For backward compatibility, the "private" bit is set too. rdar://problem/36755912 llvm-svn: 346210
* os_log: Minor code cleanups. NFC.Akira Hatanaka2018-11-062-5/+4
| | | | | | Also, add a new test case and fix an incorrect comment. llvm-svn: 346209
* Revert r345562: "PR23833, DR2140: an lvalue-to-rvalue conversion on a ↵Richard Smith2018-11-031-5/+0
| | | | | | | | | | | | glvalue of type" This exposes a (known) CodeGen bug: it can't cope with emitting lvalue expressions that denote non-odr-used but usable-in-constant-expression variables. See PR39528 for a testcase. Reverted for now until that issue can be fixed. llvm-svn: 346065
* Reapply Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-027-0/+2840
| | | | | | | | | | | | The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers. This also moves the OSLog and other FormatString helpers from libclangAnalysis to libclangAST to avoid a circular dependency. llvm-svn: 345971
* Add support for 'atomic_default_mem_order' clause on 'requires' directive. ↵Patrick Lyster2018-11-023-5/+16
| | | | | | Also renamed test files relating to 'requires'. Differntial review: https://reviews.llvm.org/D53513 llvm-svn: 345967
* Revert "Reapply Logging: make os_log buffer size an integer constant ↵Tim Northover2018-11-013-211/+0
| | | | | | | | expression." Still more dependency hell. llvm-svn: 345871
* Reapply Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-013-0/+211
| | | | | | | | | | | | The size of an os_log buffer is known at any stage of compilation, so making it a constant expression means that the common idiom of declaring a buffer for it won't result in a VLA. That allows the compiler to skip saving and restoring the stack pointer around such buffers. This also moves the OSLog helpers from libclangAnalysis to libclangAST to avoid a circular dependency. llvm-svn: 345866
* Replace two fallthrough annotations after covered switch with unreachableReid Kleckner2018-11-011-4/+2
| | | | | | | | | | | | | Both preceding switches handle all possible enumerators, so the fallthrough is actually unreachable. This strengthens that to an assertion. The first instance had a comment from 2010 indicating that fallthrough was possible, but that was back when we had a unary operator for offsetof. Now it is its own expression kind, so the annotation was stale. llvm-svn: 345862
* Revert "Logging: make os_log buffer size an integer constant expression.Tim Northover2018-11-012-8/+0
| | | | | | | | This also reverts a couple of follow-up commits trying to fix the dependency issues. Latest revision added a cyclic dependency that can't just be patched up in 5 minutes. llvm-svn: 345846
OpenPOWER on IntegriCloud