aboutsummaryrefslogtreecommitdiff
path: root/clang/docs
AgeCommit message (Collapse)Author
2019-01-15[clang][UBSan] Sanitization for alignment assumptions.Roman Lebedev
Summary: UB isn't nice. It's cool and powerful, but not nice. Having a way to detect it is nice though. [[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says: ``` We propose to add this functionality via a library function instead of a core language attribute. ... If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour. ``` This differential teaches clang to sanitize all the various variants of this assume-aligned attribute. Requires D54588 for LLVM IRBuilder changes. The compiler-rt part is D54590. This is a second commit, the original one was r351105, which was mass-reverted in r351159 because 2 compiler-rt tests were failing. Reviewers: ABataev, craig.topper, vsk, rsmith, rnk, #sanitizers, erichkeane, filcab, rjmccall Reviewed By: rjmccall Subscribers: chandlerc, ldionne, EricWF, mclow.lists, cfe-commits, bkramer Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54589 llvm-svn: 351177
2019-01-15Revert alignment assumptions changesVlad Tsyrklevich
Revert r351104-6, r351109, r351110, r351119, r351134, and r351153. These changes fail on the sanitizer bots. llvm-svn: 351159
2019-01-14[clang][UBSan] Sanitization for alignment assumptions.Roman Lebedev
Summary: UB isn't nice. It's cool and powerful, but not nice. Having a way to detect it is nice though. [[ https://wg21.link/p1007r3 | P1007R3: std::assume_aligned ]] / http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1007r2.pdf says: ``` We propose to add this functionality via a library function instead of a core language attribute. ... If the pointer passed in is not aligned to at least N bytes, calling assume_aligned results in undefined behaviour. ``` This differential teaches clang to sanitize all the various variants of this assume-aligned attribute. Requires D54588 for LLVM IRBuilder changes. The compiler-rt part is D54590. Reviewers: ABataev, craig.topper, vsk, rsmith, rnk, #sanitizers, erichkeane, filcab, rjmccall Reviewed By: rjmccall Subscribers: chandlerc, ldionne, EricWF, mclow.lists, cfe-commits, bkramer Tags: #sanitizers Differential Revision: https://reviews.llvm.org/D54589 llvm-svn: 351105
2019-01-10fixup: sphinx warningNick Desaulniers
Fixes the sphinx warning: tools/clang/docs/DiagnosticsReference.rst:7889: WARNING: Title underline too short. That I just introduced in r350877. llvm-svn: 350878
2019-01-10[SemaCXX] add -Woverride-init alias to -Winitializer-overridesNick Desaulniers
Summary: https://bugs.llvm.org/show_bug.cgi?id=40251 https://github.com/ClangBuiltLinux/linux/issues/307 Reviewers: rsmith Reviewed By: rsmith Subscribers: cfe-commits, nathanchance, srhines Differential Revision: https://reviews.llvm.org/D56522 llvm-svn: 350877
2019-01-09[OpenMP] Add flag for preventing the extension to 64 bits for the collapse ↵Gheorghe-Teodor Bercea
loop counter Summary: Introduce a compiler flag for cases when the user knows that the collapsed loop counter can be safely represented using at most 32 bits. This will prevent the emission of expensive mathematical operations (such as the div operation) on the iteration variable using 64 bits where 32 bit operations are sufficient. Reviewers: ABataev, caomhin Reviewed By: ABataev Subscribers: hfinkel, kkwli0, guansong, cfe-commits Differential Revision: https://reviews.llvm.org/D55928 llvm-svn: 350758
2019-01-09[OPENMP][DOCS]Release notes/OpenMP support updates, NFC.Alexey Bataev
llvm-svn: 350757
2019-01-08__has_feature(pragma_clang_attribute_namespaces) should be __has_extensionErik Pilkington
Thanks to Richard Smith for pointing this out. llvm-svn: 350642
2019-01-07Add a __has_feature check for namespaces on #pragma clang attribute.Erik Pilkington
Support for this was added in r349845. llvm-svn: 350572
2019-01-07[clang] Add AST matcher for initializer list membersHyrum Wright
Summary: Much like hasArg for various call expressions, this allows LibTooling users to match against a member of an initializer list. This is currently being used as part of the abseil-duration-scale clang-tidy check. Differential Revision: https://reviews.llvm.org/D56090 llvm-svn: 350523
2019-01-04[ObjCARC] Add an new attribute, objc_externally_retainedErik Pilkington
This attribute, called "objc_externally_retained", exposes clang's notion of pseudo-__strong variables in ARC. Pseudo-strong variables "borrow" their initializer, meaning that they don't retain/release it, instead assuming that someone else is keeping their value alive. If a function is annotated with this attribute, implicitly strong parameters of that function aren't implicitly retained/released in the function body, and are implicitly const. This is useful to expose for performance reasons, most functions don't need the extra safety of the retain/release, so programmers can opt out as needed. This attribute can also apply to declarations of local variables, with similar effect. Differential revision: https://reviews.llvm.org/D55865 llvm-svn: 350422
2019-01-01Fix some typos in the clang doc.Sylvestre Ledru
Fixed with: $ codespell -w ClangFormatStyleOptions.rst Toolchain.rst LanguageExtensions.rst ClangCommandLineReference.rst llvm-svn: 350192
2019-01-01clang-format-diff: add an example with hgSylvestre Ledru
llvm-svn: 350191
2018-12-20Add support for namespaces on #pragma clang attributeErik Pilkington
Namespaces are introduced by adding an "identifier." before a push/pop directive. Pop directives with namespaces can only pop a attribute group that was pushed with the same namespace. Push and pop directives that don't opt into namespaces have the same semantics. This is necessary to prevent a pitfall of using multiple #pragma clang attribute directives spread out in a large file, particularly when macros are involved. It isn't easy to see which pop corripsonds to which push, so its easy to inadvertently pop the wrong group. Differential revision: https://reviews.llvm.org/D55628 llvm-svn: 349845
2018-12-19Portable Python script across Python versionSerge Guelton
urllib2 as been renamed into urllib and the library layout has changed. Workaround that in a consistent manner. Differential Revision: https://reviews.llvm.org/D55199 llvm-svn: 349627
2018-12-18Portable Python script across Python versionSerge Guelton
Make scripts more future-proof by importing most __future__ stuff. Differential Revision: https://reviews.llvm.org/D55208 llvm-svn: 349504
2018-12-18Portable Python script across Python versionSerge Guelton
Using from __future__ import print_function it is possible to have a compatible behavior of `print(...)` across Python version. Differential Revision: https://reviews.llvm.org/D55213 llvm-svn: 349454
2018-12-18Portable Python script across Python versionSerge Guelton
dict no longer have the `has_key` method in Python3. Instead, one can use the `in` keyword which already works in Python2. llvm-svn: 349447
2018-12-17[ASTImporter] Fix redecl chain of classes and class templatesGabor Marton
Summary: The crux of the issue that is being fixed is that lookup could not find previous decls of a friend class. The solution involves making the friend declarations visible in their decl context (i.e. adding them to the lookup table). Also, we simplify `VisitRecordDecl` greatly. This fix involves two other repairs (without these the unittests fail): (1) We could not handle the addition of injected class types properly when a redecl chain was involved, now this is fixed. (2) DeclContext::removeDecl failed if the lookup table in Vector form did not contain the to be removed element. This caused troubles in ASTImporter::ImportDeclContext. This is also fixed. Reviewers: a_sidorin, balazske, a.sidorin Subscribers: rnkovacs, dkrupp, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D53655 llvm-svn: 349349
2018-12-16[analyzer] Fix some expressions staying live too long. Add a debug checker.Artem Dergachev
StaticAnalyzer uses the CFG-based RelaxedLiveVariables analysis in order to, in particular, figure out values of which expressions are still needed. When the expression becomes "dead", it is garbage-collected during the dead binding scan. Expressions that constitute branches/bodies of control flow statements, eg. `E1' in `if (C1) E1;' but not `E2' in `if (C2) { E2; }', were kept alive for too long. This caused false positives in MoveChecker because it relies on cleaning up loop-local variables when they go out of scope, but some of those live-for-too-long expressions were keeping a reference to those variables. Fix liveness analysis to correctly mark these expressions as dead. Add a debug checker, debug.DumpLiveStmts, in order to test expressions liveness. Differential Revision: https://reviews.llvm.org/D55566 llvm-svn: 349320
2018-12-14Implement -frecord-command-line (-frecord-gcc-switches)Scott Linder
Implement options in clang to enable recording the driver command-line in an ELF section. Implement a new special named metadata, llvm.commandline, to support frontends embedding their command-line options in IR/ASM/ELF. This differs from the GCC implementation in some key ways: * In GCC there is only one command-line possible per compilation-unit, in LLVM it mirrors llvm.ident and multiple are allowed. * In GCC individual options are separated by NULL bytes, in LLVM entire command-lines are separated by NULL bytes. The advantage of the GCC approach is to clearly delineate options in the face of embedded spaces. The advantage of the LLVM approach is to support merging multiple command-lines unambiguously, while handling embedded spaces with escaping. Differential Revision: https://reviews.llvm.org/D54487 Clang Differential Revision: https://reviews.llvm.org/D54489 llvm-svn: 349155
2018-12-13[clang] Add AST matcher for block expressions 🔍Stephane Moore
Summary: This change adds a new AST matcher for block expressions. Test Notes: Ran the clang unit tests. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55546 llvm-svn: 349004
2018-12-12[AST] Store "UsesADL" information in CallExpr.Eric Fiselier
Summary: Currently the Clang AST doesn't store information about how the callee of a CallExpr was found. Specifically if it was found using ADL. However, this information is invaluable to tooling. Consider a tool which renames usages of a function. If the originally CallExpr was formed using ADL, then the tooling may need to additionally qualify the replacement. Without information about how the callee was found, the tooling is left scratching it's head. Additionally, we want to be able to match ADL calls as quickly as possible, which means avoiding computing the answer on the fly. This patch changes `CallExpr` to store whether it's callee was found using ADL. It does not change the size of any AST nodes. Reviewers: fowles, rsmith, klimek, shafik Reviewed By: rsmith Subscribers: aaron.ballman, riccibruno, calabrese, titus, cfe-commits Differential Revision: https://reviews.llvm.org/D55534 llvm-svn: 348977
2018-12-11Stop stripping comments from AST matcher example code.Aaron Ballman
The AST matcher documentation dumping script was being a bit over-zealous about stripping comment markers, which ended up causing comments in example code to stop being comments. Fix that by only stripping comments at the start of a line, rather than removing any forward slash (which also impacts prose text). llvm-svn: 348891
2018-12-11[ASan] Minor documentation fix: clarify static linking limitation.Max Moroz
Summary: ASan does not support statically linked binaries, but ASan runtime itself can be statically linked into a target binary executable. Reviewers: eugenis, kcc Reviewed By: eugenis Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D55066 llvm-svn: 348863
2018-12-06Fix title underlines being too short after r348429Pete Cooper
llvm-svn: 348431
2018-12-05Update ARC docs as objc_storeStrong returns void not idPete Cooper
llvm-svn: 348429
2018-12-05Mention changes to libc++ include dir lookup in release notes.Ilya Biryukov
Summary: The change itself landed as r348365, see the comment for more details. Reviewers: arphaman, EricWF Reviewed By: arphaman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D55322 llvm-svn: 348394
2018-12-05[asan] Add clang flag -fsanitize-address-use-odr-indicatorVitaly Buka
Reviewers: eugenis, m.ostapenko, ygribov Subscribers: hiraditya, llvm-commits Differential Revision: https://reviews.llvm.org/D55157 llvm-svn: 348327
2018-12-04Remove reference to recently removed PTH Documentation.Erich Keane
Removed in r348266 Change-Id: Icff0212f57c42ca84ec174ddd4366ae63a7923fa llvm-svn: 348268
2018-12-04PTH-- Remove feature entirely-Erich Keane
When debugging a boost build with a modified version of Clang, I discovered that the PTH implementation stores TokenKind in 8 bits. However, we currently have 368 TokenKinds. The result is that the value gets truncated and the wrong token gets picked up when including PTH files. It seems that this will go wrong every time someone uses a token that uses the 9th bit. Upon asking on IRC, it was brought up that this was a highly experimental features that was considered a failure. I discovered via googling that BoostBuild (mostly Boost.Math) is the only user of this feature, using the CC1 flag directly. I believe that this can be transferred over to normal PCH with minimal effort: https://github.com/boostorg/build/issues/367 Based on advice on IRC and research showing that this is a nearly completely unused feature, this patch removes it entirely. Note: I considered leaving the build-flags in place and making them emit an error/warning, however since I've basically identified and warned the only user, it seemed better to just remove them. Differential Revision: https://reviews.llvm.org/D54547 Change-Id: If32744275ef1f585357bd6c1c813d96973c4d8d9 llvm-svn: 348266
2018-12-03Portable Python script across versionSerge Guelton
Have all classes derive from object: that's implicitly the default in Python3, it needs to be done explicilty in Python2. Differential Revision: https://reviews.llvm.org/D55121 llvm-svn: 348127
2018-11-27[docs] UBSan and ASan are supported on WindowsReid Kleckner
Also fix a bullet list. Fixes PR39775 llvm-svn: 347633
2018-11-22Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet
Breaks some buildbots. llvm-svn: 347463
2018-11-22[ASTMatchers] Add hasSideEffect() matcher.Clement Courbet
Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
2018-11-22[ASTMatchers] Re-generate ast matchers doc after rL346455.Clement Courbet
llvm-svn: 347453
2018-11-20[clang][Parse] Diagnose useless null statements / empty init-statementsRoman Lebedev
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
2018-11-20Update the documentation for attribute feature tests.Aaron Ballman
This clarifies that __has_cpp_attribute is no longer always an extension since it's now available in C++2a. Also, Both __has_cpp_attribute and __has_c_attribute can accept attribute scope tokens with alternative spelling (clang vs _Clang and gnu vs __gnu__). llvm-svn: 347312
2018-11-19[clang][CodeGen] Implicit Conversion Sanitizer: discover the world of ↵Roman Lebedev
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
2018-11-17[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet
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
2018-11-13UserManual: Tweak the /Zc:dllexportInlines- docs someHans Wennborg
Addressing comments on https://reviews.llvm.org/D54319 llvm-svn: 346748
2018-11-12Revert rL346644, rL346642: the added test ↵Calixte Denizet
test/CodeGen/code-coverage-filter.c is failing under windows llvm-svn: 346659
2018-11-12[Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet
filter the files to instrument with gcov Summary: These options are taking regex separated by colons to filter files. - if both are empty then all files are instrumented - if -fprofile-filter-files is empty then all the filenames matching any of the regex from exclude are not instrumented - if -fprofile-exclude-files is empty then all the filenames matching any of the regex from filter are instrumented - if both aren't empty then all the filenames which match any of the regex in filter and which don't match all the regex in filter are instrumented - this patch is a follow-up of https://reviews.llvm.org/D52033 Reviewers: marco-c, vsk Reviewed By: marco-c, vsk Subscribers: cfe-commits, sylvestre.ledru Differential Revision: https://reviews.llvm.org/D52034 llvm-svn: 346642
2018-11-12Release notes: Mention clang-cl's /Zc:dllexportInlines- flagHans Wennborg
llvm-svn: 346640
2018-11-12clang-cl: Add documentation for /Zc:dllexportInlines-Hans Wennborg
Differential revision: https://reviews.llvm.org/D54319 llvm-svn: 346639
2018-11-09[ASTMatchers] overload ignoringParens for ExprJonas Toth
Summary: This patch allows fixing PR39583. Reviewers: aaron.ballman, sbenza, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54307 llvm-svn: 346554
2018-11-08clang-cl: Add "/clang:" pass-through arg support.Hans Wennborg
The clang-cl driver disables access to command line options outside of the "Core" and "CLOption" sets of command line arguments. This filtering makes it impossible to pass arguments that are interpreted by the clang driver and not by either 'cc1' (the frontend) or one of the other tools invoked by the driver. An example driver-level flag is the '-fno-slp-vectorize' flag, which is processed by the driver in Clang::ConstructJob and used to set the cc1 flag "-vectorize-slp". There is no negative cc1 flag or -mllvm flag, so it is not currently possible to disable the SLP vectorizer from the clang-cl driver. This change introduces the "/clang:" argument that is available when the driver mode is set to CL compatibility. This option works similarly to the "-Xclang" option, except that the option values are processed by the clang driver rather than by 'cc1'. An example usage is: clang-cl /clang:-fno-slp-vectorize /O2 test.c Another example shows how "/clang:" can be used to pass a flag where there is a conflict between a clang-cl compat option and an overlapping clang driver option: clang-cl /MD /clang:-MD /clang:-MF /clang:test_dep_file.dep test.c In the previous example, the unprefixed /MD selects the DLL version of the msvc CRT, while the prefixed -MD flag and the -MF flags are used to create a make dependency file for included headers. One note about flag ordering: the /clang: flags are concatenated to the end of the argument list, so in cases where the last flag wins, the /clang: flags will be chosen regardless of their order relative to other flags on the driver command line. Patch by Neeraj K. Singh! Differential revision: https://reviews.llvm.org/D53457 llvm-svn: 346393
2018-11-04Update our URLs in clang doc to use httpsSylvestre Ledru
llvm-svn: 346101
2018-11-02Change -fsanitize-address-poison-class-member-array-new-cookie to ↵Filipe Cabecinhas
-fsanitize-address-poison-custom-array-cookie Handle it in the driver and propagate it to cc1 Reviewers: rjmccall, kcc, rsmith Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52615 llvm-svn: 346001
2018-10-31[clang] try-fix broken documentation builderJonas Toth
llvm-svn: 345737