summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert r347417 "Re-Reinstate 347294 with a fix for the failures."Hans Wennborg2018-11-2731-350/+187
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Revert r347627 "[MS] Push fewer DeclContexts for delayed template parsing"Reid Kleckner2018-11-271-7/+2
| | | | | | | | | | | It broke the Windows self-host: http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/1799/steps/stage%202%20build/logs/stdio I can build lib/CodeGen/CMakeFiles/LLVMCodeGen.dir/MachinePostDominators.cpp.obj to repro. llvm-svn: 347630
* [analyzer][PlistMacroExpansion] Part 3.: Macro arguments are expandedKristof Umann2018-11-271-22/+197
| | | | | | | | This part focuses on expanding macro arguments. Differential Revision: https://reviews.llvm.org/D52795 llvm-svn: 347629
* Revert "[clang][slh] add attribute for speculative load hardening"Zola Bridges2018-11-272-7/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | until I figure out why the build is failing or timing out *************************** Summary: The prior diff had to be reverted because there were two tests that failed. I updated the two tests in this diff clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCXX/attr-speculative-load-hardening.cpp LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54915 This reverts commit a5b3c232d1e3613f23efbc3960f8e23ea70f2a79. (r347617) llvm-svn: 347628
* [MS] Push fewer DeclContexts for delayed template parsingReid Kleckner2018-11-271-2/+7
| | | | | | | | | | | | | Only push the outermost record as a DeclContext when parsing a function body. See the comments in Sema::getContainingDC about the way the parser pushes contexts. This is intended to match the behavior the parser normally displays where it parses all method bodies from all nested classes at the end of the outermost class, when all nested classes are complete. Fixes PR38460. llvm-svn: 347627
* [clang][slh] add attribute for speculative load hardeningZola Bridges2018-11-272-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The prior diff had to be reverted because there were two tests that failed. I updated the two tests in this diff clang/test/Misc/pragma-attribute-supported-attributes-list.test clang/test/SemaCXX/attr-speculative-load-hardening.cpp ----- Summary from Previous Diff (Still Accurate) ----- LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54915 llvm-svn: 347617
* Revert "[clang][slh] add attribute for speculative load hardening"Zola Bridges2018-11-262-7/+0
| | | | | | This reverts commit 801eaf91221ba6dd6996b29ff82659ad6359e885. llvm-svn: 347588
* [clang][slh] add attribute for speculative load hardeningZola Bridges2018-11-262-0/+7
| | | | | | | | | | | | | | | | | | Summary: LLVM IR already has an attribute for speculative_load_hardening. Before this commit, when a user passed the -mspeculative-load-hardening flag to Clang, every function would have this attribute added to it. This Clang attribute will allow users to opt into SLH on a function by function basis. This can be applied to functions and Objective C methods. Reviewers: chandlerc, echristo Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54555 llvm-svn: 347586
* [OPENMP][NVPTX]Emit default locations with the correct Exec|RuntimeAlexey Bataev2018-11-262-15/+47
| | | | | | | | | | | modes. If the region is inside target|teams|distribute region, we can emit the locations with the correct info for execution mode and runtime mode. Patch adds this ability to the NVPTX codegen to help the optimizer to produce better code. llvm-svn: 347583
* [clang][slh] Forward mSLH only to Clang CC1Zola Bridges2018-11-261-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: -mno-speculative-load-hardening isn't a cc1 option, therefore, before this change: clang -mno-speculative-load-hardening hello.cpp would have the following error: error: unknown argument: '-mno-speculative-load-hardening' This change will only ever forward -mspeculative-load-hardening which is a CC1 option based on which flag was passed to clang. Also added a test that uses this option that fails if an error like the above is ever thrown. Thank you ericwf for help debugging and fixing this error. Reviewers: chandlerc, EricWF Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D54763 llvm-svn: 347582
* [NFC] Replace magic numbers with CodeGenOpt enumsSam Parker2018-11-261-6/+6
| | | | | | | Use enum values from llvm/Support/CodeGen.h for the optimisation levels in CompilerInvocation. llvm-svn: 347577
* [AArch64] Add aarch64_vector_pcs function attribute to ClangSander de Smalen2018-11-268-9/+33
| | | | | | | | | | | | | | | | | | | | 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
* [Index] Expose USR generation for typesIlya Biryukov2018-11-261-0/+11
| | | | | | | | | | | | | | Summary: Used in clangd. Reviewers: sammccall, ioeric Reviewed By: sammccall Subscribers: kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D52275 llvm-svn: 347558
* [PowerPC] Vector load/store builtins overstate alignment of pointersNemanja Ivanovic2018-11-261-24/+39
| | | | | | | | | | | | | A number of builtins in altivec.h load/store vectors from pointers to scalar types. Currently they just cast the pointer to a vector pointer, but expressions like that have the alignment of the target type. Of course, the input pointer did not have that alignment so this triggers UBSan (and rightly so). This resolves https://bugs.llvm.org/show_bug.cgi?id=39704 Differential revision: https://reviews.llvm.org/D54787 llvm-svn: 347556
* 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
* [CodeComplete] Simplify CodeCompleteConsumer.cpp, NFCFangrui Song2018-11-251-77/+69
| | | | | | | | Use range-based for loops Use XStr.compare(YStr) < 0 Format misaligned code llvm-svn: 347529
* [CodeGen] translate MS rotate builtins to LLVM funnel-shift intrinsicsSanjay Patel2018-11-251-40/+10
| | | | | | | | | | | | | | This was originally part of: D50924 and should resolve PR37387: https://bugs.llvm.org/show_bug.cgi?id=37387 ...but it was reverted because some bots using a gcc host compiler would crash for unknown reasons with this included in the patch. Trying again now to see if that's still a problem. llvm-svn: 347527
* [analyzer] INT50-CPP. Do not cast to an out-of-range enumeration checkerKristof Umann2018-11-242-0/+129
| | | | | | | | | | | | | | | This checker implements a solution to the "INT50-CPP. Do not cast to an out-of-range enumeration value" rule [1]. It lands in alpha for now, and a number of followup patches are planned in order to enable it by default. [1] https://www.securecoding.cert.org/confluence/display/cplusplus/INT50-CPP.+Do+not+cast+to+an+out-of-range+enumeration+value Patch by: Endre Fülöp and Alexander Zaitsev! Differential Revision: https://reviews.llvm.org/D33672 llvm-svn: 347513
* isEvaluatable() implies a constant context.Bill Wendling2018-11-242-3/+10
| | | | | | | | | | 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
* [CodeComplete] Delete unused variable in rC342449Fangrui Song2018-11-241-1/+0
| | | | llvm-svn: 347508
* [CodeComplete] Format SemaCodeComplete.cpp and improve code consistencyFangrui Song2018-11-241-1187/+1135
| | | | | | | | | There are some mis-indented places and missing spaces here and there. Just format the whole file. Also, newer code (from 2014 onwards) in this file prefers const auto *X = dyn_cast to not repeat the Decl type name. Make other occurrences consistent. Remove two anonymous namespaces that are not very necessary: 1) a typedef 2) a local function (should use static) llvm-svn: 347507
* A __builtin_constant_p() returns 0 with a function type.Bill Wendling2018-11-221-1/+1
| | | | llvm-svn: 347480
* [clang-format] Do not treat asm clobber [ as ObjCExpr, refinedKrasimir Georgiev2018-11-221-5/+6
| | | | | | | | | | | | | | | | | | | Summary: r346756 refined clang-format to not treat the `[` in `asm (...: [] ..)` as an ObjCExpr. However that's not enough, as we might have a comma-separated list of such clobbers as in the newly added test. This updates the detection to instead look at the Line's first token being `asm` and not mark `[`-s as ObjCExprs in this case. Reviewers: djasper, benhamilton Reviewed By: djasper, benhamilton Subscribers: benhamilton, cfe-commits Differential Revision: https://reviews.llvm.org/D54795 llvm-svn: 347465
* Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet2018-11-221-1/+0
| | | | | | Breaks some buildbots. llvm-svn: 347463
* [ASTMatchers] Add hasSideEffect() matcher.Clement Courbet2018-11-221-0/+1
| | | | | | | | | | | | Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
* The result of is.constant() is unsigned.Bill Wendling2018-11-221-1/+1
| | | | llvm-svn: 347446
* [Driver] Support XRay on FuchsiaPetr Hosek2018-11-222-2/+15
| | | | | | | | This enables support for XRay in Fuchsia Clang driver. Differential Revision: https://reviews.llvm.org/D52160 llvm-svn: 347444
* Revert "[Driver] Use --push/pop-state with Sanitizer link deps"Petr Hosek2018-11-211-2/+0
| | | | | | | This reverts commit r347413: older versions of ld.gold that are used by Android don't support --push/pop-state which broke sanitizer bots. llvm-svn: 347430
* [OPENMP][NVPTX]Emit default locations as constant with undefined mode.Alexey Bataev2018-11-214-9/+50
| | | | | | | | | | | | For the NVPTX target default locations should be emitted as constants + additional info must be emitted in the reserved_2 field of the ident_t structure. The 1st bit controls the execution mode and the 2nd bit controls use of the lightweight runtime. The combination of the bits for Non-SPMD mode + lightweight runtime represents special undefined mode, used outside of the target regions for orphaned directives or functions. Should allow and additional optimization inside of the target regions. llvm-svn: 347425
* Re-Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-2131-185/+339
| | | | | | | | | 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
* [Driver] Use --push/pop-state with Sanitizer link depsPetr Hosek2018-11-211-0/+2
| | | | | | | | | | | Sanitizer runtime link deps handling passes --no-as-needed because of PR15823, but it never undoes it and this flag may affect other libraries that come later on the link line. To avoid this, wrap Sanitizer link deps in --push/pop-state. Differential Revision: https://reviews.llvm.org/D54805 llvm-svn: 347413
* [OPENMP] Refactor code for parsing omp declare target directive and its ↵Kelvin Li2018-11-211-50/+56
| | | | | | | | | | | | | | clauses (NFC) This patch refactor the code for parsing omp declare target directive and its clauses. Patch by pjeeva01 (Jeeva P.) Differential Revision: https://reviews.llvm.org/D54708 llvm-svn: 347411
* [OPENMP]Fix handling of the LCVs in loop-based directives.Alexey Bataev2018-11-212-2/+11
| | | | | | | | | Loop-control variables with the default data-sharing attributes should not be captured in the OpenMP region as they are private by default. Also, default attributes should be emitted for such variables in the inner OpenMP regions for the correct data sharing during codegen. llvm-svn: 347409
* [OPENMP] remove redundant MapTypeModifierSpecified flag in ParseOpenMP.cpp (NFC)Kelvin Li2018-11-211-8/+1
| | | | | | | | | | | Whether the map type modifier is specified or not, the flag MapTypeModifierSpecified is always set to true. Patch by Ahsan Saghir Differential Revision: https://reviews.llvm.org/D54638 llvm-svn: 347408
* [OPENMP] Support relational-op != (not-equal) as one of the canonical Kelvin Li2018-11-211-18/+40
| | | | | | | | | | | | | | forms of random access iterator In OpenMP 4.5, only 4 relational operators are supported: <, <=, >, and >=. This work is to enable support for relational operator != (not-equal) as one of the canonical forms. Patch by Anh Tuyen Tran Differential Revision: https://reviews.llvm.org/D54441 llvm-svn: 347405
* Mark lambda decl as invalid if a captured variable has an invalid type.Jorge Gorbe Moya2018-11-211-0/+15
| | | | | | | This causes the compiler to crash when trying to compute a layout for the lambda closure type (see included test). llvm-svn: 347402
* Revert r347364 again, the fix was incomplete.Nico Weber2018-11-2131-339/+185
| | | | llvm-svn: 347389
* [Driver] Link sanitizer runtime deps on Fuchsia when neededPetr Hosek2018-11-211-2/+4
| | | | | | | | | | Even though these deps weren't needed, this makes Fuchsia driver better match other drivers, and it may be necessary when trying to use different C libraries on Fuchsia. Differential Revision: https://reviews.llvm.org/D54741 llvm-svn: 347378
* clang::tooling::Diagnostic: Don't store offset in the scratch space.Alexander Kornienko2018-11-211-2/+7
| | | | | | | | These offsets are useless (and even harmful in certain cases) in exported diagnostics. The test will be added to clang-tidy, since it's the main user of the clang::tooling::Diagnostic class. llvm-svn: 347372
* Reinstate 347294 with a fix for the failures.Bill Wendling2018-11-2031-185/+339
| | | | | | | EvaluateAsInt() is sometimes called in a constant context. When that's the case, we need to specify it as so. llvm-svn: 347364
* [CodeComplete] Penalize inherited ObjC properties for auto-completionSam McCall2018-11-201-21/+36
| | | | | | | | | | | | | | | | | | | | | Summary: Similar to auto-completion for ObjC methods, inherited properties should be penalized / direct class and category properties should be prioritized. Note that currently, the penalty for using a result from a base class (CCD_InBaseClass) is equal to the penalty for using a method as a property (CCD_MethodAsProperty). Reviewers: jkorous, sammccall, akyrtzi, arphaman, benlangmuir Reviewed By: sammccall, akyrtzi Subscribers: arphaman, cfe-commits Differential Revision: https://reviews.llvm.org/D53900 llvm-svn: 347352
* [clang][Parse] Diagnose useless null statements / empty init-statementsRoman Lebedev2018-11-202-1/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: clang has `-Wextra-semi` (D43162), which is not dictated by the currently selected standard. While that is great, there is at least one more source of need-less semis - 'null statements'. Sometimes, they are needed: ``` for(int x = 0; continueToDoWork(x); x++) ; // Ugly code, but the semi is needed here. ``` But sometimes they are just there for no reason: ``` switch(X) { case 0: return -2345; case 5: return 0; default: return 42; }; // <- oops ;;;;;;;;;;; <- OOOOPS, still not diagnosed. Clearly this is junk. ``` Additionally: ``` if(; // <- empty init-statement true) ; switch (; // empty init-statement x) { ... } for (; // <- empty init-statement int y : S()) ; } As usual, things may or may not go sideways in the presence of macros. While evaluating this diag on my codebase of interest, it was unsurprisingly discovered that Google Test macros are *very* prone to this. And it seems many issues are deep within the GTest itself, not in the snippets passed from the codebase that uses GTest. So after some thought, i decided not do issue a diagnostic if the semi is within *any* macro, be it either from the normal header, or system header. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=39111 | PR39111 ]] Reviewers: rsmith, aaron.ballman, efriedma Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52695 llvm-svn: 347339
* [AST] Store the expressions in ParenListExpr in a trailing arrayBruno Ricci2018-11-207-31/+51
| | | | | | | | | | | | 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-2010-109/+43
| | | | llvm-svn: 347314
* [clang-format] JS: don't treat is: as a type matcherKrasimir Georgiev2018-11-201-2/+15
| | | | | | | | | | | | | | | | Summary: Clang-format is treating all occurences of `is` in js as type matchers. In some cases this is wrong, as it might be a dict key. Reviewers: mprobst Reviewed By: mprobst Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54753 llvm-svn: 347307
* [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-2010-43/+109
| | | | | | | | | | | | | | | | 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
* Driver: SCS is compatible with every other sanitizer.Peter Collingbourne2018-11-201-4/+1
| | | | | | | | | | Because SCS relies on system-provided runtime support, we can use it together with any other sanitizer simply by linking the runtime for the other sanitizer. Differential Revision: https://reviews.llvm.org/D54735 llvm-svn: 347282
OpenPOWER on IntegriCloud