summaryrefslogtreecommitdiffstats
path: root/clang
Commit message (Collapse)AuthorAgeFilesLines
...
* [AArch64] Fix scalar vuqadd intrinsics operandsDiogo N. Sampaio2019-07-083-5/+31
| | | | | | | | | | | | | | | | | | | | Summary: Change the vuqadd scalar instrinsics to have the second argument as unsigned values, not signed, accordingly to https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics So now the compiler correctly warns that a undefined negative float conversion is being done. Reviewers: LukeCheeseman, john.brawn Reviewed By: john.brawn Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64242 llvm-svn: 365300
* [AArch64] Fix vsqadd scalar intrinsics operandsDiogo N. Sampaio2019-07-083-5/+54
| | | | | | | | | | | | | | | | | | | | | Summary: Change the vsqadd scalar instrinsics to have the second argument as signed values, not unsigned, accordingly to https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics The existing unsigned argument can cause faulty code as negative float to unsigned conversion is undefined, which llvm/clang optimizes away. Reviewers: LukeCheeseman, john.brawn Reviewed By: john.brawn Subscribers: john.brawn, javed.absar, kristof.beyls, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64239 llvm-svn: 365298
* Treat the range of representable values of floating-point types as [-inf, ↵Richard Smith2019-07-068-189/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | +inf] not as [-max, +max]. Summary: Prior to r329065, we used [-max, max] as the range of representable values because LLVM's `fptrunc` did not guarantee defined behavior when truncating from a larger floating-point type to a smaller one. Now that has been fixed, we can make clang follow normal IEEE 754 semantics in this regard and take the larger range [-inf, +inf] as the range of representable values. In practice, this affects two parts of the frontend: * the constant evaluator no longer treats floating-point evaluations that result in +-inf as being undefined (because they no longer leave the range of representable values of the type) * UBSan no longer treats conversions to floating-point type that are outside the [-max, +max] range as being undefined In passing, also remove the float-divide-by-zero sanitizer from -fsanitize=undefined, on the basis that while it's undefined per C++ rules (and we disallow it in constant expressions for that reason), it is defined by Clang / LLVM / IEEE 754. Reviewers: rnk, BillyONeal Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63793 llvm-svn: 365272
* [Rewrite] Try to fix buildbot link fail left by r365263Joel E. Denny2019-07-061-0/+1
| | | | | | http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10272 llvm-svn: 365264
* [Rewrite] Try to fix buildbot link fail caused by r365258Joel E. Denny2019-07-061-0/+1
| | | | | | http://lab.llvm.org:8011/builders/clang-ppc64le-linux-multistage/builds/10270 llvm-svn: 365263
* [Rewrite] Extend to further accept CharSourceRangeJoel E. Denny2019-07-064-4/+105
| | | | | | | | | | | | | Some Rewrite functions are already overloaded to accept CharSourceRange, and this extends others in the same manner. I'm calling these in code that's not ready to upstream, but I figure they might be useful to others in the meantime. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D61467 llvm-svn: 365258
* Improve MSVC visualization of annot_template_id tokensMike Spertus2019-07-051-9/+62
| | | | | | | | | Now shows the actual annotated template. E.g., {annot_template_id (A<int, double>)} Also a few miscellaneous fixes to visualizers of other types llvm-svn: 365248
* Bitstream reader: Fix undefined behavior seen after rL364464Bjorn Pettersson2019-07-051-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: After rL364464 the following tests started to fail when running the clang-doc tests with an ubsan instrumented build of clang-doc: Clang Tools :: clang-doc/single-file-public.cpp Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitEnumInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitMethodInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/BitcodeTest.emitRecordInfoBitcode Extra Tools Unit Tests :: clang-doc/./ClangDocTests/SerializeTest.emitInfoWithCommentBitcode We need to check that the read value is in range for being casted to the llvm::bitc::FixedAbbrevIDs enum, before the cast in ClangDocBitcodeReader::skipUntilRecordOrBlock. SerializedDiagnosticReader::skipUntilRecordOrBlock was updated in the same way. Reviewers: jfb Reviewed By: jfb Subscribers: Bigcheese, vsapsai, bruno, ilya-biryukov, dexonsmith, kadircet, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64262 llvm-svn: 365239
* Add a comment explaining why a function existsNico Weber2019-07-051-0/+3
| | | | llvm-svn: 365212
* NFC: Add an explicit return for safety and consistencyHamza Sood2019-07-051-0/+2
| | | | | | | This case implicitly falls-through, which is fine now as it's at the end of the function, but it seems like an accident waiting to happen. llvm-svn: 365210
* Removed the test case added in D63538 due to windows buildbot failuresKristof Umann2019-07-051-38/+0
| | | | llvm-svn: 365209
* [analyzer] Add a debug analyzer config to place an event for each tracked ↵Kristof Umann2019-07-055-7/+68
| | | | | | | | condition Differential Revision: https://reviews.llvm.org/D63642 llvm-svn: 365208
* [analyzer] Track terminator conditions on which a tracked expression dependsKristof Umann2019-07-055-1/+395
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is a major part of my GSoC project, aimed to improve the bug reports of the analyzer. TL;DR: Help the analyzer understand that some conditions are important, and should be explained better. If an CFGBlock is a control dependency of a block where an expression value is tracked, explain the condition expression better by tracking it. if (A) // let's explain why we believe A to be true 10 / x; // division by zero This is an experimental feature, and can be enabled by the off-by-default analyzer configuration "track-conditions". In detail: This idea was inspired by the program slicing algorithm. Essentially, two things are used to produce a program slice (a subset of the program relevant to a (statement, variable) pair): data and control dependencies. The bug path (the linear path in the ExplodedGraph that leads from the beginning of the analysis to the error node) enables to analyzer to argue about data dependencies with relative ease. Control dependencies are a different slice of the cake entirely. Just because we reached a branch during symbolic execution, it doesn't mean that that particular branch has any effect on whether the bug would've occured. This means that we can't simply rely on the bug path to gather control dependencies. In previous patches, LLVM's IDFCalculator, which works on a control flow graph rather than the ExplodedGraph was generalized to solve this issue. We use this information to heuristically guess that the value of a tracked expression depends greatly on it's control dependencies, and start tracking them as well. After plenty of evaluations this was seen as great idea, but still lacking refinements (we should have different descriptions about a conditions value), hence it's off-by-default. Differential Revision: https://reviews.llvm.org/D62883 llvm-svn: 365207
* [analyzer][IDF] Add a control dependency calculator + a new debug checkerKristof Umann2019-07-057-28/+326
| | | | | | | | | | | | | | | | | | | | | | | I intend to improve the analyzer's bug reports by tracking condition expressions. 01 bool b = messyComputation(); 02 int i = 0; 03 if (b) // control dependency of the bug site, let's explain why we assume val 04 // to be true 05 10 / i; // warn: division by zero I'll detail this heuristic in the followup patch, strictly related to this one however: * Create the new ControlDependencyCalculator class that uses llvm::IDFCalculator to (lazily) calculate control dependencies for Clang's CFG. * A new debug checker debug.DumpControlDependencies is added for lit tests * Add unittests Differential Revision: https://reviews.llvm.org/D62619 llvm-svn: 365197
* [NFC] Test commit accessEndre Fulop2019-07-051-1/+1
| | | | llvm-svn: 365189
* Make joined instances of JoinedOrSeparate flags point to the unaliased args, ↵Nico Weber2019-07-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | like all other arg types do This fixes an 8-year-old regression. r105763 made it so that aliases always refer to the unaliased option – but it missed the "joined" branch of JoinedOrSeparate flags. (r162231 then made the Args classes non-virtual, and r169344 moved them from clang to llvm.) Back then, there was no JoinedOrSeparate flag that was an alias, so it wasn't observable. Now /U in CLCompatOptions is a JoinedOrSeparate alias in clang, and warn_slash_u_filename incorrectly used the aliased arg id (using the unaliased one isn't really a regression since that warning checks if the undefined macro contains slash or backslash and only then emits the warning – and no valid use will pass "-Ufoo/bar" or similar). Also, lld has many JoinedOrSeparate aliases, and due to this bug it had to explicitly call `getUnaliasedOption()` in a bunch of places, even though that shouldn't be necessary by design. After this fix in Option, these calls really don't have an effect any more, so remove them. No intended behavior change. (I accidentally fixed this bug while working on PR29106 but then wondered why the warn_slash_u_filename broke. When I figured it out, I thought it would make sense to land this in a separate commit.) Differential Revision: https://reviews.llvm.org/D64156 llvm-svn: 365186
* Fix a buildbot failure due to the AST's lifetime ending before the testKristof Umann2019-07-051-17/+3
| | | | llvm-svn: 365181
* [analyzer][Dominators][NFC] Add unit testsKristof Umann2019-07-054-51/+174
| | | | | | Differential Revision: https://reviews.llvm.org/D62611 llvm-svn: 365179
* [CFG] Add a new function to get the proper condition of a CFGBlockKristof Umann2019-07-053-0/+84
| | | | | | | | | | | | | getTerminatorCondition() returned a condition that may be outside of the block, while the new function returns the proper one: if (A && B && C) {} Return C instead of A && B && C. Differential Revision: https://reviews.llvm.org/D63538 llvm-svn: 365177
* Silence gcc warning "control reaches end of non-void function" [NFCI]Mikael Holmen2019-07-051-0/+2
| | | | | | | | | | | | | | Without this fix gcc (7.4) complains with /data/repo/master/clang/lib/CodeGen/CGObjCMac.cpp: In member function 'std::__cxx11::string {anonymous}::CGObjCCommonMac::GetSectionName(llvm::StringRef, llvm::StringRef)': /data/repo/master/clang/lib/CodeGen/CGObjCMac.cpp:4944:1: error: control reaches end of non-void function [-Werror=return-type] } ^ All values in the ObjectFormatType enum are currently handled in the switch but gcc complains anyway. llvm-svn: 365174
* [NFC] Make some ObjectFormatType switches coveringHubert Tong2019-07-041-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch removes the `default` case from some switches on `llvm::Triple::ObjectFormatType`, and cases for the missing enumerators are then added. For `UnknownObjectFormat`, the action (`llvm_unreachable`) for the `default` case is kept. For the other unhandled cases, `report_fatal_error` is used instead. Reviewers: sfertile, jasonliu, daltenty Reviewed By: sfertile Subscribers: wuzish, aheejin, jsji, cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D63767 llvm-svn: 365160
* [modules] Add PP callbacks for entering and leaving a submodule.Vassil Vassilev2019-07-042-0/+46
| | | | llvm-svn: 365153
* [CTU] Add support for virtual functionsGabor Marton2019-07-044-2/+34
| | | | | | | | | | | | Reviewers: Szelethus, xazax.hun Subscribers: rnkovacs, dkrupp, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63920 llvm-svn: 365133
* Fix -Wdocumentation warning.Simon Pilgrim2019-07-041-1/+1
| | | | llvm-svn: 365126
* [PowerPC] Support constraint code "ww"Fangrui Song2019-07-042-1/+15
| | | | | | | | | | | | | Summary: "ww" and "ws" are both constraint codes for VSX vector registers that hold scalar double data. "ww" is preferred for float while "ws" is preferred for double. Reviewed By: jsji Differential Revision: https://reviews.llvm.org/D64119 llvm-svn: 365106
* [analyzer] ReturnValueChecker: Model the guaranteed boolean return value of ↵Csaba Dabis2019-07-046-6/+285
| | | | | | | | | | | | | | | | | | | function calls Summary: It models the known LLVM methods paired with their class. Reviewers: NoQ, xazax.hun, ravikandhadai, baloghadamsoftware, Szelethus Reviewed By: NoQ Subscribers: dschuff, aheejin, mgorny, szepet, rnkovacs, a.sidorin, mikhail.ramalho, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63915 llvm-svn: 365103
* cmake: Add CLANG_LINK_CLANG_DYLIB optionTom Stellard2019-07-0339-45/+86
| | | | | | | | | | | | | | | | Summary: Setting CLANG_LINK_CLANG_DYLIB=ON causes clang tools to link against libclang_shared.so instead of the individual component libraries. Reviewers: mgorny, beanz, smeenai, phosek, sylvestre.ledru Subscribers: arphaman, cfe-commits, llvm-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63503 llvm-svn: 365092
* [Bitcode] Move Bitstream to a separate libraryFrancis Visoiu Mistrih2019-07-0325-25/+28
| | | | | | | | | | | | | | | | | | | | | | | | | This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/. This is needed to avoid a circular dependency when using the bitstream code for parsing optimization remarks. Since Bitcode uses Core for the IR part: libLLVMRemarks -> Bitcode -> Core and Core uses libLLVMRemarks to generate remarks (see IR/RemarkStreamer.cpp): Core -> libLLVMRemarks we need to separate the Bitstream and Bitcode part. For clang-doc, it seems that it doesn't need the whole bitcode layer, so I updated the CMake to only use the bitstream part. Differential Revision: https://reviews.llvm.org/D63899 llvm-svn: 365091
* [analyzer] exploded-graph-rewriter: Implement a black-and-white color scheme.Artem Dergachev2019-07-032-16/+30
| | | | | | | | For accessibility! Differential Revision: https://reviews.llvm.org/D64153 llvm-svn: 365085
* [clang-scan-deps] use `-Wno-error` when scanning for dependenciesAlex Lorenz2019-07-034-0/+25
| | | | | | | | | Warnings can be promoted to errors. But that shouldn't prevent us from getting the dependencies! Differential Revision: https://reviews.llvm.org/D64149 llvm-svn: 365065
* Revert "[analyzer][CFG] Return the correct terminator condition"Kristof Umann2019-07-032-16/+62
| | | | | | | | This reverts commit 7a57118a6fcfa3770f984453543bbdfd0b233e84. Causes a bunch of crashes, I need to time to evaluate this. llvm-svn: 365037
* [analyzer][CFG] Return the correct terminator conditionKristof Umann2019-07-032-62/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For the following terminator statement: if (A && B && C && D) The built CFG is the following: [B5 (ENTRY)] Succs (1): B4 [B1] 1: 10 2: j 3: [B1.2] (ImplicitCastExpr, LValueToRValue, int) 4: [B1.1] / [B1.3] 5: int x = 10 / j; Preds (1): B2 Succs (1): B0 [B2] 1: C 2: [B2.1] (ImplicitCastExpr, LValueToRValue, _Bool) T: if [B4.4] && [B3.2] && [B2.2] Preds (1): B3 Succs (2): B1 B0 [B3] 1: B 2: [B3.1] (ImplicitCastExpr, LValueToRValue, _Bool) T: [B4.4] && [B3.2] && ... Preds (1): B4 Succs (2): B2 B0 [B4] 1: 0 2: int j = 0; 3: A 4: [B4.3] (ImplicitCastExpr, LValueToRValue, _Bool) T: [B4.4] && ... Preds (1): B5 Succs (2): B3 B0 [B0 (EXIT)] Preds (4): B1 B2 B3 B4 However, even though the path of execution in B2 only depends on C's value, CFGBlock::getCondition() would return the entire condition (A && B && C). For B3, it would return A && B. I changed this the actual condition. Differential Revision: https://reviews.llvm.org/D63538 llvm-svn: 365036
* Fix -Wcast-qual const warning. NFCI.Simon Pilgrim2019-07-031-1/+1
| | | | llvm-svn: 365031
* Make a buildbot using a buggy gcc happyKristof Umann2019-07-031-3/+5
| | | | | | | | | When specializing a template in a namespace, it has to be in a namespace block, else gcc will get confused. Hopefully this fixes the issue. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480 llvm-svn: 365030
* Specialize an anchor() function in the correct namespaceKristof Umann2019-07-031-2/+2
| | | | llvm-svn: 365029
* [analyzer][Dominator] Add post dominators to CFG + a new debug checkerKristof Umann2019-07-036-63/+224
| | | | | | | | | | | | | | | | Transform clang::DominatorTree to be able to also calculate post dominators. * Tidy up the documentation * Make it clang::DominatorTree template class (similarly to how llvm::DominatorTreeBase works), rename it to clang::CFGDominatorTreeImpl * Clang's dominator tree is now called clang::CFGDomTree * Clang's brand new post dominator tree is called clang::CFGPostDomTree * Add a lot of asserts to the dump() function * Create a new checker to test the functionality Differential Revision: https://reviews.llvm.org/D62551 llvm-svn: 365028
* [Dominators] PR42041: Skip nullpointer successorsKristof Umann2019-07-033-65/+198
| | | | | | | | | | | | | | | | | https://bugs.llvm.org/show_bug.cgi?id=42041 In Clang's CFG, we use nullpointers to represent unreachable nodes, for example, in the included testfile, block B0 is unreachable from block B1, resulting in a nullpointer dereference somewhere in llvm::DominatorTreeBase<clang::CFGBlock, false>::recalculate. This patch fixes this issue by specializing llvm::DomTreeBuilder::SemiNCAInfo::ChildrenGetter::Get for clang::CFG to not contain nullpointer successors. Differential Revision: https://reviews.llvm.org/D62507 llvm-svn: 365026
* Fix MSVC "signed/unsigned mismatch" warning. NFCI.Simon Pilgrim2019-07-031-1/+2
| | | | | | Fixes PR42426. llvm-svn: 365019
* [clang-tidy] Fix the YAML created for checks like modernize-pass-by-valueIvan Donchevskii2019-07-032-1/+31
| | | | | | | | | | | Currently this check generates the replacement with the newline in the end. The proper way to export it to YAML is to have two \n\n instead of one. Without this fix clients should reinterpret the replacement as "#include <utility> " instead of "#include <utility>\n" Differential Revision: https://reviews.llvm.org/D63482 llvm-svn: 365017
* Fix MSVC "not all control paths return a value" warnings. NFCI.Simon Pilgrim2019-07-031-0/+2
| | | | llvm-svn: 365012
* Change std::{lower,upper}_bound to llvm::{lower,upper}_bound or ↵Fangrui Song2019-07-0322-89/+58
| | | | | | llvm::partition_point. NFC llvm-svn: 365006
* [clang][HeaderSearch] Shorten paths for includes in mainfile's directoryKadir Cetinkaya2019-07-034-34/+83
| | | | | | | | | | | | | | | | | | Summary: Currently HeaderSearch only looks at SearchDir's passed into it, but in addition to those paths headers can be relative to including file's directory. This patch makes sure that is taken into account. Reviewers: gribozavr Subscribers: jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63295 llvm-svn: 365005
* [analyzer] exploded-graph-rewriter: Implement bug nodes and sink nodes.Artem Dergachev2019-07-0314-24/+72
| | | | | | | | | | | Add a label to nodes that have a bug report attached or on which the analysis was generally interrupted. Fix printing has_report and implement printing is_sink in the graph dumper. Differential Revision: https://reviews.llvm.org/D64110 llvm-svn: 364992
* [analyzer] exploded-graph-rewriter: NFC: Add more comments.Artem Dergachev2019-07-031-3/+25
| | | | llvm-svn: 364991
* [analyzer] exploded-graph-rewriter: Collapse very long statement pretty-prints.Artem Dergachev2019-07-032-3/+44
| | | | | | | | | | When printing various statements that include braces (compound statements, lambda expressions, statement-expressions, etc.), replace the code between braces with '...'. Differential Revision: https://reviews.llvm.org/D64104 llvm-svn: 364990
* [analyzer] exploded-graph-rewriter: Implement checker messages.Artem Dergachev2019-07-039-10/+239
| | | | | | | | They are displayed as raw lines and diffed via difflib on a per-checker basis. Differential Revision: https://reviews.llvm.org/D64100 llvm-svn: 364989
* [C++2a] Add __builtin_bit_cast, used to implement std::bit_castErik Pilkington2019-07-0238-9/+1334
| | | | | | | | | | | | | | | | | | This commit adds a new builtin, __builtin_bit_cast(T, v), which performs a bit_cast from a value v to a type T. This expression can be evaluated at compile time under specific circumstances. The compile time evaluation currently doesn't support bit-fields, but I'm planning on fixing this in a follow up (some of the logic for figuring this out is in CodeGen). I'm also planning follow-ups for supporting some more esoteric types that the constexpr evaluator supports, as well as extending __builtin_memcpy constexpr evaluation to use the same infrastructure. rdar://44987528 Differential revision: https://reviews.llvm.org/D62825 llvm-svn: 364954
* clang-format: Add new style option AlignConsecutiveMacrosSam McCall2019-07-026-0/+255
| | | | | | | | | | | | | | | | | | | | | | This option behaves similarly to AlignConsecutiveDeclarations and AlignConsecutiveAssignments, aligning the assignment of C/C++ preprocessor macros on consecutive lines. I've worked in many projects (embedded, mostly) where header files full of large, well-aligned "#define" blocks are a common pattern. We normally avoid using clang-format on these files, since it ruins any existing alignment in said blocks. This style option will align "simple" PP macros (no parameters) and PP macros with parameter lists on consecutive lines. Related Bugzilla entry (thanks mcuddie): https://llvm.org/bugs/show_bug.cgi?id=20637 Patch by Nick Renieris (VelocityRa)! Differential Revision: https://reviews.llvm.org/D28462 llvm-svn: 364938
* [LibTooling] Extend `RewriteRule` with support for adding includes.Yitzhak Mandelbaum2019-07-023-4/+81
| | | | | | | | | | | | | | | | | | Summary: This revision allows users to specify the insertion of an included directive (at the top of the file being rewritten) as part of a rewrite rule. These directives are bundled with `RewriteRule` cases, so that different cases can potentially result in different include actions. Reviewers: ilya-biryukov, gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63892 llvm-svn: 364917
* [clang][ArgumentAdjusters] Do not add fsyntax-only if already existsKadir Cetinkaya2019-07-022-1/+32
| | | | | | | | | | | | Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64063 llvm-svn: 364904
OpenPOWER on IntegriCloud