summaryrefslogtreecommitdiffstats
path: root/clang/lib
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] PR43102: Fix an assertion and an out-of-bounds error for ↵Kristof Umann2019-09-182-8/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | diagnostic location construction Summary: https://bugs.llvm.org/show_bug.cgi?id=43102 In today's edition of "Is this any better now that it isn't crashing?", I'd like to show you a very interesting test case with loop widening. Looking at the included test case, it's immediately obvious that this is not only a false positive, but also a very bad bug report in general. We can see how the analyzer mistakenly invalidated `b`, instead of its pointee, resulting in it reporting a null pointer dereference error. Not only that, the point at which this change of value is noted at is at the loop, rather then at the method call. It turns out that `FindLastStoreVisitor` works correctly, rather the supplied explodedgraph is faulty, because `BlockEdge` really is the `ProgramPoint` where this happens. {F9855739} So it's fair to say that this needs improving on multiple fronts. In any case, at least the crash is gone. Full ExplodedGraph: {F9855743} Reviewers: NoQ, xazax.hun, baloghadamsoftware, Charusso, dcoughlin, rnkovacs, TWeaver Subscribers: JesperAntonsson, uabelho, Ka-Ka, bjope, whisperity, szepet, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66716 llvm-svn: 372269
* On PowerPC, Secure-PLT by default for FreeBSD 13 and higherDimitry Andric2019-09-181-1/+2
| | | | | | | | | | | | | | | | | | | Summary: In https://svnweb.freebsd.org/changeset/base/349351, FreeBSD 13 and higher transitioned to Secure-PLT for PowerPC. This part contains the changes in clang's PPC architecture defaults. Reviewers: emaste, jhibbits, hfinkel Reviewed By: jhibbits Subscribers: wuzish, nemanjai, krytarowski, kbarton, MaskRay, jsji, shchenz, steven.zhang, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67119 llvm-svn: 372261
* [OPENMP]Fix for PR43349: Crash for privatized loop bound.Alexey Bataev2019-09-181-0/+16
| | | | | | | | If the variable, used in the loop boundaries, is not captured in the construct, this variable must be considered as undefined if it was privatized. llvm-svn: 372252
* [clang-format][PR41899] PointerAlignment: Left leads to useless space in ↵Paul Hoad2019-09-181-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | lambda intializer expression Summary: https://bugs.llvm.org/show_bug.cgi?id=41899 ```auto lambda = [&a = a]() { a = 2; };``` is formatted as ```auto lambda = [& a = a]() { a = 2; };``` With an extra space if PointerAlignment is set to Left > The space "& a" looks strange when there is no type in the lambda's intializer expression. This can be worked around with by setting "PointerAlignment: Right", but ideally "PointerAlignment: Left" would not add a space in this case. Reviewers: klimek, owenpan, krasimir, timwoj Reviewed By: klimek Subscribers: cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D67718 llvm-svn: 372249
* make -frewrite-includes also rewrite conditions in #if/#elifLubos Lunak2019-09-181-120/+54
| | | | | | | | | | | | | | | Those conditions may use __has_include, which needs to be rewritten. The existing code has already tried to rewrite just __has_include, but it didn't work with macro expansion, so e.g. Qt's "#define QT_HAS_INCLUDE(x) __has_include(x)" didn't get handled properly. Since the preprocessor run knows what each condition evaluates to, just rewrite the entire condition. This of course requires that the -frewrite-include pass has the same setup as the following compilation, but that has always been the requirement. Differential Revision: https://reviews.llvm.org/D63508 llvm-svn: 372248
* [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhdErik Pilkington2019-09-182-0/+18
| | | | | | | | | | | Also, add a diagnostic under -Wformat for printing a boolean value as a character. rdar://54579473 Differential revision: https://reviews.llvm.org/D66856 llvm-svn: 372247
* [clang-format][PR41964] Fix crash with SIGFPE when TabWidth is set to 0 and ↵Paul Hoad2019-09-183-17/+26
| | | | | | | | | | | | | | | | | | | | | | | | | line starts with tab Summary: clang-format 8.0 crashes with SIGFPE (floating point exception) when formatting following file: app.cpp: void a() { //line starts with '\t' } $ clang-format -style='{TabWidth: 0}' app.cpp Reviewers: owenpan, klimek, russellmcc, timwoj Reviewed By: klimek Subscribers: cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D67670 llvm-svn: 372246
* [c++20] P1331R2: Allow transient use of uninitialized objects inRichard Smith2019-09-184-118/+220
| | | | | | constant evaluation. llvm-svn: 372237
* [OPENMP5.0]Allow multiple context selectors in the context selectorAlexey Bataev2019-09-183-100/+128
| | | | | | | | | sets. According to OpenMP 5.0, context selector set might include several context selectors, separated with commas. Patch fixes this problem. llvm-svn: 372235
* Revert r372082 "[Clang] Pragma vectorize_width() implies vectorize(enable)"Hans Wennborg2019-09-181-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This broke the Chromium build. Consider the following code: float ScaleSumSamples_C(const float* src, float* dst, float scale, int width) { float fsum = 0.f; int i; #if defined(__clang__) #pragma clang loop vectorize_width(4) #endif for (i = 0; i < width; ++i) { float v = *src++; fsum += v * v; *dst++ = v * scale; } return fsum; } Compiling at -Oz, Clang now warns: $ clang++ -target x86_64 -Oz -c /tmp/a.cc /tmp/a.cc:1:7: warning: loop not vectorized: the optimizer was unable to perform the requested transformation; the transformation might be disabled or specified as part of an unsupported transformation ordering [-Wpass-failed=transform-warning] this suggests it's not actually enabling vectorization hard enough. At -Os it asserts instead: $ build.release/bin/clang++ -target x86_64 -Os -c /tmp/a.cc clang-10: /work/llvm.monorepo/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp:2734: void llvm::InnerLoopVectorizer::emitMemRuntimeChecks(llvm::Loop*, llvm::BasicBlock*): Assertion ` !BB->getParent()->hasOptSize() && "Cannot emit memory checks when optimizing for size"' failed. Of course neither of these are what the developer expected from the pragma. > Specifying the vectorization width was supposed to implicitly enable > vectorization, except that it wasn't really doing this. It was only > setting the vectorize.width metadata, but not vectorize.enable. > > This should fix PR27643. > > Differential Revision: https://reviews.llvm.org/D66290 llvm-svn: 372225
* [mips] Pass "xgot" flag as a subtarget featureSimon Atanasyan2019-09-182-7/+7
| | | | | | | | | We need "xgot" flag in the MipsAsmParser to implement correct expansion of some pseudo instructions in case of using 32-bit GOT (XGOT). MipsAsmParser does not have reference to MipsSubtarget but has a reference to "feature bit set". llvm-svn: 372220
* [AST] CommentLexer - Remove (optional) Invalid parameter from getSpelling.Simon Pilgrim2019-09-181-5/+2
| | | | | | The static analyzer noticed that we were dereferencing it even when the default null value was being used. Further investigation showed that we never explicitly set the parameter so I've just removed it entirely. llvm-svn: 372217
* [lldb] Print better diagnostics for user expressions and modulesRaphael Isemann2019-09-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently our expression evaluators only prints very basic errors that are not very useful when writing complex expressions. For example, in the expression below the user made a type error, but it's not clear from the diagnostic what went wrong: ``` (lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) error: invalid operands to binary expression ('int' and 'double') ``` This patch enables full Clang diagnostics in our expression evaluator. After this patch the diagnostics for the expression look like this: ``` (lldb) expr printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) error: <user expression 1>:1:54: invalid operands to binary expression ('int' and 'float') printf("Modulos are:", foobar%mo1, foobar%mo2, foobar%mo3) ~~~~~~^~~~ ``` To make this possible, we now emulate a user expression file within our diagnostics. This prevents that the user is exposed to our internal wrapper code we inject. Note that the diagnostics that refer to declarations from the debug information (e.g. 'note' diagnostics pointing to a called function) will not be improved by this as they don't have any source locations associated with them, so caret or line printing isn't possible. We instead just suppress these diagnostics as we already do with warnings as they would otherwise just be a context message without any context (and the original diagnostic in the user expression should be enough to explain the issue). Fixes rdar://24306342 Reviewers: JDevlieghere, aprantl, shafik, #lldb Reviewed By: JDevlieghere, #lldb Subscribers: usaxena95, davide, jingham, aprantl, arphaman, kadircet, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D65646 llvm-svn: 372203
* [ARM] Update clang for removal of vfp2d16 and vfp2d16spEli Friedman2019-09-172-4/+3
| | | | | | | | Matching fix for https://reviews.llvm.org/D67375 (r372186). Differential Revision: https://reviews.llvm.org/D67467 llvm-svn: 372187
* [Sema] Split of versions of -Wimplicit-{float,int}-conversion for ↵Erik Pilkington2019-09-172-28/+65
| | | | | | | | | | | | | Objective-C BOOL Also, add a diagnostic group, -Wobjc-signed-char-bool, to control all these related diagnostics. rdar://51954400 Differential revision: https://reviews.llvm.org/D67559 llvm-svn: 372183
* Ignore exception specifier mismatch when merging redeclarationsReid Kleckner2019-09-171-1/+6
| | | | | | | | | | | | | | | | | | Exception specifiers are now part of the function type in C++17. Normally, it is illegal to redeclare the same function or specialize a template with a different exception specifier, but under -fms-compatibility, we accept it with a warning. Without this change, the function types would not match due to the exception specifier, and clang would claim that the types were "incompatible". Now we emit the warning and merge the redeclaration as we would in C++14 and earlier. Fixes PR42842, which is about compiling _com_ptr_t in C++17. Based on a patch by Alex Fusco <alexfusco@google.com>! Differential Revision: https://reviews.llvm.org/D67590 llvm-svn: 372178
* [OPENMP5.0]Introduce attribute for declare variant directive.Alexey Bataev2019-09-173-1/+87
| | | | | | | | Added attribute for declare variant directive. It will allow to handle declare variant directive at the codegen and will allow to add extra checks. llvm-svn: 372147
* [clang-format] Fix cleanup of `AnnotatedLine` to include children nodes.Yitzhak Mandelbaum2019-09-171-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: AnnotatedLine has a tree structure, and things like the body of a lambda will be a child of the lambda expression. For example, [&]() { foo(a); }; will have an AnnotatedLine with a child: [&]() {}; '- foo(a); Currently, when the `Cleaner` class analyzes the affected lines, it does not cleanup the lines' children nodes, which results in missed cleanup opportunities, like the lambda body in the example above. This revision extends the algorithm to visit children, thereby fixing the above problem. Patch by Eric Li. Reviewers: krasimir Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67659 llvm-svn: 372129
* Add SpellingNotCalculated to Attribute Enums to suppress UBSan warningsErich Keane2019-09-173-0/+8
| | | | | | | UBSan downstreams noticed that the assignment of SpellingNotCalculated to the spellings caused warnings. llvm-svn: 372124
* [OpenCL] Tidy up some comments; NFCSven van Haastregt2019-09-171-10/+4
| | | | llvm-svn: 372119
* Hide implementation details in namespaces.Benjamin Kramer2019-09-171-0/+2
| | | | llvm-svn: 372113
* [Clang] Pragma vectorize_width() implies vectorize(enable)Sjoerd Meijer2019-09-171-0/+8
| | | | | | | | | | | | Specifying the vectorization width was supposed to implicitly enable vectorization, except that it wasn't really doing this. It was only setting the vectorize.width metadata, but not vectorize.enable. This should fix PR27643. Differential Revision: https://reviews.llvm.org/D66290 llvm-svn: 372082
* [RISCV] Define __riscv_cmodel_medlow and __riscv_cmodel_medany correctlyKito Cheng2019-09-171-2/+8
| | | | | | | | | | | | | | RISC-V LLVM was only implement small/medlow code model, so it defined __riscv_cmodel_medlow directly without check. Now, we have medium/medany code model in RISC-V back-end, it should define according the actually code model. Reviewed By: lewis-revill Differential Revision: https://reviews.llvm.org/D67065 llvm-svn: 372078
* Fix reliance on -flax-vector-conversions in AVX intrinsics headers andRichard Smith2019-09-171-2/+2
| | | | | | corresponding tests. llvm-svn: 372063
* Remove reliance on lax vector conversions from altivec.h in VSX mode.Richard Smith2019-09-171-19/+22
| | | | llvm-svn: 372061
* Push lambda scope earlier when transforming lambda expressionNicholas Allegra2019-09-171-4/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D66067 llvm-svn: 372058
* [Modules][Objective-C] Use complete decl from module when diagnosing missing ↵Bruno Cardoso Lopes2019-09-161-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | import Summary: Otherwise the definition (first found) for ObjCInterfaceDecl's might precede the module one, which will eventually lead to crash, since diagnoseMissingImport needs one coming from a module. This behavior changed after Richard's r342018, which started to look into the definition of ObjCInterfaceDecls. rdar://problem/49237144 Reviewers: rsmith, arphaman Subscribers: jkorous, dexonsmith, ributzka, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66982 llvm-svn: 372039
* do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614)Lubos Lunak2019-09-161-1/+2
| | | | | | | | | | | -frewrite-includes calls PP.SetMacroExpansionOnlyInDirectives() to avoid macro expansions that are useless in that mode, but this can lead to -Wunused-macros false positives. As -frewrite-includes does not emit normal warnings, block -Wunused-macros too. Differential Revision: https://reviews.llvm.org/D65371 llvm-svn: 372026
* [OPENMP]Fix parsing/sema for function templates with declare simd.Alexey Bataev2019-09-161-1/+1
| | | | | | | | Need to return original declaration group with FunctionTemplateDecl, not the inner FunctionDecl, to correctly handle parsing of directives with the templates parameters. llvm-svn: 372011
* Move some definitions from Sema to Basic to fix shared libs buildErich Keane2019-09-162-71/+74
| | | | | | | | r371875 moved some functionality around to a Basic header file, but didn't move its definitions as well. This patch moves some things around so that shared library building can work. llvm-svn: 371985
* [OpenMP] Fix OMPClauseReader::readClause() uninitialized variable warning. NFCI.Simon Pilgrim2019-09-151-1/+3
| | | | | | Fixes static analyzer uninitialized variable warning for the OMPClause - the function appears to cover all cases, but I've added an assertion to make sure. llvm-svn: 371934
* [Diagnostics] Added silence note for -Wsizeof-array-div; suggest extra parensDavid Bolvansky2019-09-141-0/+2
| | | | llvm-svn: 371924
* [Driver] Fix multiple bugs related to dependency file options: -M -MM -MD ↵Fangrui Song2019-09-142-32/+38
| | | | | | | | | | | -MMD -MT -MQ -M -o test.i => dependency file is test.d, not test.i -MM -o test.i => dependency file is test.d, not test.i -M -MMD => bogus warning -Wunused-command-line-argument -M MT dummy => -w not rendered llvm-svn: 371918
* [Driver] Improve Clang::getDependencyFileName and its tests after rC371853Fangrui Song2019-09-141-1/+1
| | | | | | | The test file name metadata-with-dots.c is confusing because -MD and -MMD have nothing to do with metadata. llvm-svn: 371917
* [WebAssembly] Narrowing and widening SIMD opsThomas Lively2019-09-131-0/+57
| | | | | | | | | | | | | | | | Summary: Implements target-specific LLVM intrinsics and clang builtins for these new SIMD operations, as described at https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#integer-to-integer-narrowing. Reviewers: aheejin Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D67425 llvm-svn: 371906
* [clang-scan-deps] Fix for headers having the same name as a directoryAlex Lorenz2019-09-131-0/+3
| | | | | | | | | | | | Scan deps tool crashes when called on a C++ file, containing an include that has the same name as a directory. The tool crashes since it finds foo/dir and tries to read that as a file and fails. Patch by: kousikk (Kousik Kumar) Differential Revision: https://reviews.llvm.org/D67091 llvm-svn: 371903
* [OPENMP5.0]Add basic support for declare variant directive.Alexey Bataev2019-09-136-85/+428
| | | | | | | Added basic support for declare variant directive and its match clause with user context selector. llvm-svn: 371892
* [Support] Add overload writeFileAtomically(std::function Writer)Jan Korous2019-09-132-47/+14
| | | | | | Differential Revision: https://reviews.llvm.org/D67424 llvm-svn: 371890
* Reland r371785: Add -Wpoison-system-directories warningManoj Gupta2019-09-131-0/+7
| | | | | | | | | | | | | | | | | | | | When using clang as a cross-compiler, we should not use system headers to do the compilation. This CL adds support of a new warning flag -Wpoison-system-directories which emits warnings if --sysroot is set and headers from common host system location are used. By default the warning is disabled. The intention of the warning is to catch bad includes which are usually generated by third party build system not targeting cross-compilation. Such cases happen in Chrome OS when someone imports a new package or upgrade one to a newer version from upstream. This is reland of r371785 with a fix to test file. Patch by: denik (Denis Nikitin) llvm-svn: 371878
* [NFCI]Create CommonAttributeInfo Type as base type of *Attr and ParsedAttr.Erich Keane2019-09-1322-858/+585
| | | | | | | | | | | | In order to enable future improvements to our attribute diagnostics, this moves info from ParsedAttr into CommonAttributeInfo, then makes this type the base of the *Attr and ParsedAttr types. Quite a bit of refactoring took place, including removing a bunch of redundant Spelling Index propogation. Differential Revision: https://reviews.llvm.org/D67368 llvm-svn: 371875
* [Sema][Typo Correction] Fix potential infite loop on ambiguity checksDavid Goldman2019-09-131-0/+4
| | | | | | | | | | | | | | | | | | | | | | Summary: This fixes a bug introduced in D62648, where Clang could infinite loop if it became stuck on a single TypoCorrection when it was supposed to be testing ambiguous corrections. Although not a common case, it could happen if there are multiple possible corrections with the same edit distance. The fix is simply to wipe the TypoExpr from the `TransformCache` so that the call to `TransformTypoExpr` doesn't use the `CachedEntry`. Reviewers: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67515 llvm-svn: 371859
* clang-format: Add support for formatting (some) lambdas with explicit ↵Nico Weber2019-09-132-3/+22
| | | | | | | | | | | | | | template parameters. This patch makes cases work where the lambda's template list doesn't contain any of + - ! ~ / % << | || && ^ == != >= <= ? : true false (see added FIXME). Ports r359967 to clang-format. Differential Revision: https://reviews.llvm.org/D67246 llvm-svn: 371854
* Fix depfile name constructionLuke Cheeseman2019-09-131-6/+5
| | | | | | | | | | | | | | - When using -o, the provided filename is using for constructing the depfile name (when -MMD is passed). - The logic looks for the rightmost '.' character and replaces what comes after with 'd'. - This works incorrectly when the filename has no extension and the directories have '.' in them (e.g. out.dir/test) - This replaces the funciton to just llvm::sys::path functionality Differential Revision: https://reviews.llvm.org/D67542 llvm-svn: 371853
* [Clang Interpreter] Initial patch for the constexpr interpreterNandor Licker2019-09-1350-265/+8363
| | | | | | | | | | | | | | | | | | Summary: This patch introduces the skeleton of the constexpr interpreter, capable of evaluating a simple constexpr functions consisting of if statements. The interpreter is described in more detail in the RFC. Further patches will add more features. Reviewers: Bigcheese, jfb, rsmith Subscribers: bruno, uenoku, ldionne, Tyker, thegameg, tschuett, dexonsmith, mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64146 llvm-svn: 371834
* [Clang][ASTImporter] Added visibility check for FunctionTemplateDecl.Balazs Keri2019-09-131-11/+10
| | | | | | | | | | | | | | | | | | Summary: ASTImporter makes now difference between function templates with same name in different translation units if these are not visible outside. Reviewers: martong, a.sidorin, shafik, a_sidorin Reviewed By: a_sidorin Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67490 llvm-svn: 371820
* For PR17164: split -fno-lax-vector-conversion into three differentRichard Smith2019-09-133-9/+35
| | | | | | | | | | | | | | | | | | | | | levels: -- none: no lax vector conversions [new GCC default] -- integer: only conversions between integer vectors [old GCC default] -- all: all conversions between same-size vectors [Clang default] For now, Clang still defaults to "all" mode, but per my proposal on cfe-dev (2019-04-10) the default will be changed to "integer" as soon as that doesn't break lots of testcases. (Eventually I'd like to change the default to "none" to match GCC and general sanity.) Following GCC's behavior, the driver flag -flax-vector-conversions is translated to -flax-vector-conversions=integer. This reinstates r371805, reverted in r371813, with an additional fix for lldb. llvm-svn: 371817
* Remove reliance on lax vector conversions from altivec.h and its test.Richard Smith2019-09-131-17/+23
| | | | llvm-svn: 371814
* Revert "For PR17164: split -fno-lax-vector-conversion into three different"Jonas Devlieghere2019-09-133-35/+9
| | | | | | | This breaks the LLDB build. I tried reaching out to Richard, but haven't gotten a reply yet. llvm-svn: 371813
* For PR17164: split -fno-lax-vector-conversion into three differentRichard Smith2019-09-133-9/+35
| | | | | | | | | | | | | | | | | | levels: -- none: no lax vector conversions [new GCC default] -- integer: only conversions between integer vectors [old GCC default] -- all: all conversions between same-size vectors [Clang default] For now, Clang still defaults to "all" mode, but per my proposal on cfe-dev (2019-04-10) the default will be changed to "integer" as soon as that doesn't break lots of testcases. (Eventually I'd like to change the default to "none" to match GCC and general sanity.) Following GCC's behavior, the driver flag -flax-vector-conversions is translated to -flax-vector-conversions=integer. llvm-svn: 371805
* Revert r371785.Manoj Gupta2019-09-131-7/+0
| | | | | | r371785 is causing fails on clang-hexagon-elf buildbots. llvm-svn: 371799
OpenPOWER on IntegriCloud