summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [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
* [Coverage] Fix PR39258: support coverage regions that start deeper than they endVedant Kumar2018-11-191-11/+42
| | | | | | | | | | | popRegions used to assume that the start location of a region can't be nested deeper than the end location, which is not always true. Patch by Orivej Desh! Differential Revision: https://reviews.llvm.org/D53244 llvm-svn: 347262
* [Sema] Fix PR38987: keep end location of a direct initializer listVedant Kumar2018-11-191-1/+4
| | | | | | | | | | | | | | If PerformConstructorInitialization of a direct initializer list constructor is called while instantiating a template, it has brace locations in its BraceLoc arguments but not in the Kind argument. This reverts the hunk https://reviews.llvm.org/D41921#inline-468844. Patch by Orivej Desh! Differential Revision: https://reviews.llvm.org/D53231 llvm-svn: 347261
* [clang][CodeGen] Implicit Conversion Sanitizer: discover the world of ↵Roman Lebedev2018-11-191-10/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CompoundAssign operators Summary: As reported by @regehr (thanks!) on twitter (https://twitter.com/johnregehr/status/1057681496255815686), we (me) has completely forgot about the binary assignment operator. In AST, it isn't represented as separate `ImplicitCastExpr`'s, but as a single `CompoundAssignOperator`, that does all the casts internally. Which means, out of these two, only the first one is diagnosed: ``` auto foo() { unsigned char c = 255; c = c + 1; return c; } auto bar() { unsigned char c = 255; c += 1; return c; } ``` https://godbolt.org/z/JNyVc4 This patch does handle the `CompoundAssignOperator`: ``` int main() { unsigned char c = 255; c += 1; return c; } ``` ``` $ ./bin/clang -g -fsanitize=integer /tmp/test.c && ./a.out /tmp/test.c:3:5: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned) #0 0x2392b8 in main /tmp/test.c:3:5 #1 0x7fec4a612b16 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x22b16) #2 0x214029 in _start (/build/llvm-build-GCC-release/a.out+0x214029) ``` However, the pre/post increment/decrement is still not handled. Reviewers: rsmith, regehr, vsk, rjmccall, #sanitizers Reviewed By: rjmccall Subscribers: mclow.lists, cfe-commits, regehr Tags: #clang, #sanitizers Differential Revision: https://reviews.llvm.org/D53949 llvm-svn: 347258
* [DebugInfo] DISubprogram flags get their own flags word. NFC.Paul Robinson2018-11-191-18/+30
| | | | | | | | | | | | | This will hold flags specific to subprograms. In the future we could potentially free up scarce bits in DIFlags by moving subprogram-specific flags from there to the new flags word. This patch does not change IR/bitcode formats, that will be done in a follow-up. Differential Revision: https://reviews.llvm.org/D54597 llvm-svn: 347239
* [OpenMP] Check target architecture supports unified shared memory for ↵Patrick Lyster2018-11-194-50/+118
| | | | | | requires directive. Differential Review: https://reviews.llvm.org/D54493 llvm-svn: 347214
* [FileManager] getFile(open=true) after getFile(open=false) should open the file.Sam McCall2018-11-191-19/+32
| | | | | | | | | | | | | | | | | | | Summary: Old behavior is to just return the cached entry regardless of opened-ness. That feels buggy (though I guess nobody ever actually needed this). This came up in the context of clangd+clang-tidy integration: we're going to getFile(open=false) to replay preprocessor actions obscured by the preamble, but the compilation may subsequently getFile(open=true) for non-preamble includes. Reviewers: ilya-biryukov Subscribers: ioeric, kadircet, cfe-commits Differential Revision: https://reviews.llvm.org/D54691 llvm-svn: 347205
* Fixed uninitialized variable issue.Anastasia Stulova2018-11-191-1/+1
| | | | | | This commit should fix failing bots. llvm-svn: 347196
* [OpenCL] Fix address space deduction in template args.Anastasia Stulova2018-11-191-1/+3
| | | | | | | | | | | Don't deduce address spaces for non-pointer-like types in template args. Fixes PR38603! Differential Revision: https://reviews.llvm.org/D54634 llvm-svn: 347189
* [PowerPC] Set the default PLT mode on OpenBSD/powerpc to Secure PLT.Brad Smith2018-11-192-4/+8
| | | | | | OpenBSD/powerpc only supports Secure PLT. llvm-svn: 347179
* [analyzer][NFC] Move CheckerOptInfo to CheckerRegistry.cpp, and make it localKristof Umann2018-11-182-31/+55
| | | | | | | | | CheckerOptInfo feels very much out of place in CheckerRegistration.cpp, so I moved it to CheckerRegistry.h. Differential Revision: https://reviews.llvm.org/D54397 llvm-svn: 347157
* [analyzer][UninitializedObjectChecker] Uninit regions are only reported onceKristof Umann2018-11-183-18/+64
| | | | | | | | | | Especially with pointees, a lot of meaningless reports came from uninitialized regions that were already reported. This is fixed by storing all reported fields to the GDM. Differential Revision: https://reviews.llvm.org/D51531 llvm-svn: 347153
* [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet2018-11-173-0/+29
| | | | | | | | | | | | | | | | | | filter the files to instrument with gcov (after revert https://reviews.llvm.org/rL346659) Summary: the previous patch (https://reviews.llvm.org/rC346642) has been reverted because of test failure under windows. So this patch fix the test cfe/trunk/test/CodeGen/code-coverage-filter.c. Reviewers: marco-c Reviewed By: marco-c Subscribers: cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D54600 llvm-svn: 347144
* Sink BuryPointer from Clang into LLVM for reuse thereDavid Blaikie2018-11-175-20/+9
| | | | llvm-svn: 347141
* [AST][NFC] Pack CXXDefaultInitExprBruno Ricci2018-11-172-6/+7
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultInitExpr. llvm-svn: 347138
* [AST][NFC] Pack CXXDefaultArgExprBruno Ricci2018-11-171-1/+1
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves one pointer per CXXDefaultArgExpr. llvm-svn: 347137
* [AST][NFC] Pack CXXThrowExprBruno Ricci2018-11-171-3/+3
| | | | | | | Use the newly available space in the bit-fields of Stmt. This saves 8 bytes per CXXThrowExpr. llvm-svn: 347136
* Fix unused variable warning.David L. Jones2018-11-171-0/+2
| | | | llvm-svn: 347133
* [OPENMP]Fix PR39694: do not capture `this` in non-`this` region.Alexey Bataev2018-11-161-2/+9
| | | | | | | | | If lambda is used inside of the OpenMP region and captures `this`, we should recapture it in the OpenMP region also. But we should do this only if the OpenMP region is used in the context of the same class, just like the lambda. llvm-svn: 347096
* [OPENMP][NVPTX]Emit correct reduction code for teams/parallelAlexey Bataev2018-11-162-165/+246
| | | | | | | | | | | reductions. Fixed previously committed code for the reduction support in teams/parallel constructs taking into account new design of the NVPTX support in the compiler. Teams reduction are not fully functional yet, it is going to be fixed in the following patches. llvm-svn: 347081
* Revert "[PowerPC] Make no-PIC default to match GCC - CLANG"Stefan Pintilie2018-11-161-0/+3
| | | | | | This reverts commit r347070 llvm-svn: 347075
* [codeview] Expose -gcodeview-ghash for global type hashingReid Kleckner2018-11-163-1/+12
| | | | | | | | | | | | | | | | | | | | | Summary: Experience has shown that the functionality is useful. It makes linking optimized clang with debug info for me a lot faster, 20s to 13s. The type merging phase of PDB writing goes from 10s to 3s. This removes the LLVM cl::opt and replaces it with a metadata flag. After this change, users can do the following to use ghash: - add -gcodeview-ghash to compiler flags - replace /DEBUG with /DEBUG:GHASH in linker flags Reviewers: zturner, hans, thakis, takuto.ikuta Subscribers: aprantl, hiraditya, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54370 llvm-svn: 347072
* [PowerPC] Make no-PIC default to match GCC - CLANGStefan Pintilie2018-11-161-3/+0
| | | | | | | | Make the default -fno-PIC on Power PC. Differential Revision: https://reviews.llvm.org/D53384 llvm-svn: 347070
* [OpenCL] Enable address spaces for references in C++Anastasia Stulova2018-11-167-31/+71
| | | | | | | | | | | | | 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
* [clang] - Simplify tools::SplitDebugName.George Rimar2018-11-165-20/+9
| | | | | | | | | | | | | This should be NFC change. SplitDebugName recently started to accept the `Output` that can be used to simplify the logic a bit, also it seems that code in SplitDebugName that uses OPT_fdebug_compilation_dir is simply dead. Differential revision: https://reviews.llvm.org/D54576 llvm-svn: 347035
* [Clang][Sema]Choose a better candidate in overload function call if there is ↵Zi Xuan Wu2018-11-161-0/+25
| | | | | | | | | | | | | | | | | | | | | | a compatible vector conversion instead of ambiguous call error There are 2 function variations with vector type parameter. When we call them with argument of different vector type we would prefer to choose the variation with implicit argument conversion of compatible vector type instead of incompatible vector type. For example, typedef float __v4sf __attribute__((__vector_size__(16))); void f(vector float); void f(vector signed int); int main { __v4sf a; f(a); } Here, we'd like to choose f(vector float) but not report an ambiguous call error. Differential revision: https://reviews.llvm.org/D53417 llvm-svn: 347019
* [analyzer] ConversionChecker: handle floating pointKristof Umann2018-11-161-10/+45
| | | | | | | | | | | | | | | | | Extend the alpha.core.Conversion checker to handle implicit converions where a too large integer value is converted to a floating point type. Each floating point type has a range where it can exactly represent all integers; we emit a warning when the integer value is above this range. Although it is possible to exactly represent some integers which are outside of this range (those that are divisible by a large enough power of 2); we still report cast involving those, because their usage may lead to bugs. (For example, if 1<<24 is stored in a float variable x, then x==x+1 holds.) Patch by: Donát Nagy! Differential Revision: https://reviews.llvm.org/D52730 llvm-svn: 347006
* Fix parens warning in assert in ASTMatchFinderErich Keane2018-11-151-7/+7
| | | | | Change-Id: Ie34f9c6846b98fba87449e73299519fc2346bac1 llvm-svn: 346996
* [AST] Store the string data in StringLiteral in a trailing array of charsBruno Ricci2018-11-153-87/+111
| | | | | | | | | | | | | | | | | | | | | | | | | 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-152-4/+5
| | | | | | | | | | | | 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
* Fix warning about unused variable [NFC]Mikael Holmen2018-11-151-2/+2
| | | | llvm-svn: 346950
* NFC cleanup: Prefer make_unique over reset(new T())David Blaikie2018-11-151-40/+43
| | | | llvm-svn: 346929
* Fix combining pragma __debug dump & parser_crash with -EDavid Blaikie2018-11-152-4/+5
| | | | | | | | | | | | | | | | | | | | | | | Previously these would be transformed into annotation tokens and the preprocessor would then assume they were real tokens with source locations and assert/UB. Other pragmas that produce annotation tokens aren't a problem because they aren't handled if the parser isn't hooked up - ParsePragma.cpp registers those handlers & isn't run for pure preprocessing. So they're treated as unknown pragmas & printed verbatim by the preprocessor. Perhaps these pragmas should be treated the same way? But they got mixed in with other __debug pragmas that do need to be handled during preprocessing. The third __debug pragma that produces an annotation token is 'captured' - which had its own fix for this issue - by not inserting the annotation token in the first place if it detected that it was in preprocessing mode. I've removed that fix (from Lex/Pragma.cpp) in favor of the more general one in Frontend/PrintPreprocessedOutput.cpp. llvm-svn: 346928
* Rewrite-imports on crash: Simplify handlingDavid Blaikie2018-11-151-1/+1
| | | | | | | | | | -frewrite-imports already implies -frewrite-includes (it piggy-backs on/extends the implementation) so there's no need to conditionally pass -frewrite-includes when already using -frewrite-imports (& especially I don't think these would want to be different between crash reporting and not crash reporting) llvm-svn: 346927
* CGDecl::emitStoresForConstant fix synthesized constant's nameJF Bastien2018-11-151-19/+47
| | | | | | | | | | | | Summary: The name of the synthesized constants for constant initialization was using mangling for statics, which isn't generally correct and (in a yet-uncommitted patch) causes the mangler to assert out because the static ends up trying to mangle function parameters and this makes no sense. Instead, mangle to `"__const." + FunctionName + "." + DeclName`. Reviewers: rjmccall Subscribers: dexonsmith, cfe-commits Differential Revision: https://reviews.llvm.org/D54055 llvm-svn: 346915
* [codeview] Make "clang -g" emit codeview by default when targetting MSVCReid Kleckner2018-11-142-15/+31
| | | | | | | | | | | | | | | | | | | | Summary: If you're using the Microsoft ABI, chances are that you want PDBs and codeview debug info. Currently, everyone has to remember to specific -gcodeview by default, when it would be nice if the standard -g option did the right thing by default. Also, do some related cleanup of -cc1 options. When targetting the MS C++ ABI, we probably shouldn't pass -debugger-tuning=gdb. We were also passing -gcodeview twice, which is silly. Reviewers: smeenai, zturner Subscribers: aprantl, JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D54499 llvm-svn: 346907
* [c++20] Implement P0482R6: enable -fchar8_t by default in C++20 mode.Richard Smith2018-11-145-8/+37
| | | | | | | | | | | | | This unfortunately results in a substantial breaking change when switching to C++20, but it's not yet clear what / how much we should do about that. We may want to add a compatibility conversion from u8 string literals to const char*, similar to how C++98 provided a compatibility conversion from string literals to non-const char*, but that's not handled by this patch. The feature can be disabled in C++20 mode with -fno-char8_t. llvm-svn: 346892
* [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
* Reverted D52835 to fix review commentsDavid Bolvansky2018-11-141-40/+8
| | | | llvm-svn: 346866
OpenPOWER on IntegriCloud