summaryrefslogtreecommitdiffstats
path: root/clang/docs
Commit message (Collapse)AuthorAgeFilesLines
...
* [docs] UBSan and ASan are supported on WindowsReid Kleckner2018-11-272-1/+11
| | | | | | | | Also fix a bullet list. Fixes PR39775 llvm-svn: 347633
* Revert rL347462 "[ASTMatchers] Add hasSideEffect() matcher."Clement Courbet2018-11-221-18/+0
| | | | | | Breaks some buildbots. llvm-svn: 347463
* [ASTMatchers] Add hasSideEffect() matcher.Clement Courbet2018-11-221-0/+18
| | | | | | | | | | | | Summary: Exposes Expr::HasSideEffects. Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D54830 llvm-svn: 347462
* [ASTMatchers] Re-generate ast matchers doc after rL346455.Clement Courbet2018-11-221-0/+11
| | | | llvm-svn: 347453
* [clang][Parse] Diagnose useless null statements / empty init-statementsRoman Lebedev2018-11-201-0/+57
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update the documentation for attribute feature tests.Aaron Ballman2018-11-201-18/+23
| | | | | | 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
* [clang][CodeGen] Implicit Conversion Sanitizer: discover the world of ↵Roman Lebedev2018-11-191-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet2018-11-172-0/+55
| | | | | | | | | | | | | | | | | | 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
* UserManual: Tweak the /Zc:dllexportInlines- docs someHans Wennborg2018-11-131-7/+8
| | | | | | Addressing comments on https://reviews.llvm.org/D54319 llvm-svn: 346748
* Revert rL346644, rL346642: the added test ↵Calixte Denizet2018-11-122-55/+0
| | | | | | test/CodeGen/code-coverage-filter.c is failing under windows llvm-svn: 346659
* [Clang] Add options -fprofile-filter-files and -fprofile-exclude-files to ↵Calixte Denizet2018-11-122-0/+55
| | | | | | | | | | | | | | | | | | | | | | 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
* Release notes: Mention clang-cl's /Zc:dllexportInlines- flagHans Wennborg2018-11-121-0/+5
| | | | llvm-svn: 346640
* clang-cl: Add documentation for /Zc:dllexportInlines-Hans Wennborg2018-11-121-0/+76
| | | | | | Differential revision: https://reviews.llvm.org/D54319 llvm-svn: 346639
* [ASTMatchers] overload ignoringParens for ExprJonas Toth2018-11-091-0/+11
| | | | | | | | | | | | | | | | 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
* clang-cl: Add "/clang:" pass-through arg support.Hans Wennborg2018-11-081-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Update our URLs in clang doc to use httpsSylvestre Ledru2018-11-0430-756/+755
| | | | llvm-svn: 346101
* Change -fsanitize-address-poison-class-member-array-new-cookie to ↵Filipe Cabecinhas2018-11-022-6/+8
| | | | | | | | | | | | | | -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
* [clang] try-fix broken documentation builderJonas Toth2018-10-311-0/+1
| | | | llvm-svn: 345737
* [clang][ubsan] Implicit Conversion Sanitizer - integer sign change - clang partRoman Lebedev2018-10-302-8/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is the second half of Implicit Integer Conversion Sanitizer. It completes the first half, and finally makes the sanitizer fully functional! Only the bitfield handling is missing. Summary: C and C++ are interesting languages. They are statically typed, but weakly. The implicit conversions are allowed. This is nice, allows to write code while balancing between getting drowned in everything being convertible, and nothing being convertible. As usual, this comes with a price: ``` void consume(unsigned int val); void test(int val) { consume(val); // The 'val' is `signed int`, but `consume()` takes `unsigned int`. // If val is negative, then consume() will be operating on a large // unsigned value, and you may or may not have a bug. // But yes, sometimes this is intentional. // Making the conversion explicit silences the sanitizer. consume((unsigned int)val); } ``` Yes, there is a `-Wsign-conversion`` diagnostic group, but first, it is kinda noisy, since it warns on everything (unlike sanitizers, warning on an actual issues), and second, likely there are cases where it does **not** warn. The actual detection is pretty easy. We just need to check each of the values whether it is negative, and equality-compare the results of those comparisons. The unsigned value is obviously non-negative. Zero is non-negative too. https://godbolt.org/g/w93oj2 We do not have to emit the check *always*, there are obvious situations where we can avoid emitting it, since it would **always** get optimized-out. But i do think the tautological IR (`icmp ult %x, 0`, which is always false) should be emitted, and the middle-end should cleanup it. This sanitizer is in the `-fsanitize=implicit-conversion` group, and is a logical continuation of D48958 `-fsanitize=implicit-integer-truncation`. As for the ordering, i'we opted to emit the check **after** `-fsanitize=implicit-integer-truncation`. At least on these simple 16 test cases, this results in 1 of the 12 emitted checks being optimized away, as compared to 0 checks being optimized away if the order is reversed. This is a clang part. The compiler-rt part is D50251. Finishes fixing [[ https://bugs.llvm.org/show_bug.cgi?id=21530 | PR21530 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=37552 | PR37552 ]], [[ https://bugs.llvm.org/show_bug.cgi?id=35409 | PR35409 ]]. Finishes partially fixing [[ https://bugs.llvm.org/show_bug.cgi?id=9821 | PR9821 ]]. Finishes fixing https://github.com/google/sanitizers/issues/940. Only the bitfield handling is missing. Reviewers: vsk, rsmith, rjmccall, #sanitizers, erichkeane Reviewed By: rsmith Subscribers: chandlerc, filcab, cfe-commits, regehr Tags: #sanitizers, #clang Differential Revision: https://reviews.llvm.org/D50250 llvm-svn: 345660
* Revert "Revert "Support for groups of attributes in #pragma clang attribute""Erik Pilkington2018-10-292-9/+11
| | | | | | | This reverts commit r345487, which reverted r345486. I think the crashes were caused by an OOM on the builder, trying again to confirm... llvm-svn: 345517
* Add the isStaticLocal() AST matcher for matching on local static variables.Aaron Ballman2018-10-291-0/+12
| | | | | | Patch by Joe Ranieri. llvm-svn: 345502
* Revert "Support for groups of attributes in #pragma clang attribute"Erik Pilkington2018-10-292-11/+9
| | | | | | | | | This reverts commit r345486. Looks like it causes some old versions of GCC to crash, I'll see if I can work around it and recommit... llvm-svn: 345487
* Support for groups of attributes in #pragma clang attributeErik Pilkington2018-10-292-9/+11
| | | | | | | | | | | | | | | | | | This commit enables pushing an empty #pragma clang attribute push, then adding multiple attributes to it, then popping them all with #pragma clang attribute pop, just like #pragma clang diagnostic. We still support the current way of adding these, #pragma clang attribute push(__attribute__((...))), by treating it like a combined push/attribute. This is needed to create macros like: DO_SOMETHING_BEGIN(attr1, attr2, attr3) // ... DO_SOMETHING_END rdar://45496947 Differential revision: https://reviews.llvm.org/D53621 llvm-svn: 345486
* PR26547: alignof should return ABI alignment, not preferred alignmentRichard Smith2018-10-261-0/+20
| | | | | | | | | | | | Summary: - Add `UETT_PreferredAlignOf` to account for the difference between `__alignof` and `alignof` - `AlignOfType` now returns ABI alignment instead of preferred alignment iff clang-abi-compat > 7, and one uses _Alignof or alignof Patch by Nicole Mazzuca! Differential Revision: https://reviews.llvm.org/D53207 llvm-svn: 345419
* Update the example of BS_Stroustrup to match what is done by clang-formatSylvestre Ledru2018-10-261-9/+6
| | | | | | | | | | | | | | | | | | Summary: reported here https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=911561 clang-format-7 -style="{BreakBeforeBraces: Stroustrup}" wasn't doing the same as the doc Reviewers: krasimir Reviewed By: krasimir Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D53520 llvm-svn: 345371
* Hopefully fix the documentation generation issueSylvestre Ledru2018-10-221-2/+4
| | | | llvm-svn: 344939
* Generate ClangFormatStyleOptions.rst from Format.h (using ↵Sylvestre Ledru2018-10-221-14/+42
| | | | | | docs/tools/dump_format_style.py) llvm-svn: 344934
* [Hexagon] Remove support for V4Krzysztof Parzyszek2018-10-191-1/+1
| | | | llvm-svn: 344786
* [Doc] fix second error in UsersManualJonas Toth2018-10-121-1/+1
| | | | llvm-svn: 344388
* [Doc] fix BB, add code-block typeJonas Toth2018-10-121-1/+1
| | | | llvm-svn: 344382
* Update user's manual documentation of profile remapping file to matchRichard Smith2018-10-111-5/+8
| | | | | | | | llvm-cxxmap documentation. Add a hint as to how to perform off-line profile data remapping. llvm-svn: 344319
* [clang][ubsan] Split Implicit Integer Truncation Sanitizer into unsigned and ↵Roman Lebedev2018-10-111-2/+11
| | | | | | | | | | | | | | | | | | | | signed checks Summary: As per IRC disscussion, it seems we really want to have more fine-grained `-fsanitize=implicit-integer-truncation`: * A check when both of the types are unsigned. * Another check for the other cases (either one of the types is signed, or both of the types is signed). This is clang part. Compiler-rt part is D50902. Reviewers: rsmith, vsk, Sanitizers Reviewed by: rsmith Differential Revision: https://reviews.llvm.org/D50901 llvm-svn: 344230
* Update documentation to indicate that profile remapping support is onlyRichard Smith2018-10-101-0/+6
| | | | | | implemented for the new pass manager so far. llvm-svn: 344201
* Add a flag to remap manglings when reading profile data information.Richard Smith2018-10-102-0/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | This can be used to preserve profiling information across codebase changes that have widespread impact on mangled names, but across which most profiling data should still be usable. For example, when switching from libstdc++ to libc++, or from the old libstdc++ ABI to the new ABI, or even from a 32-bit to a 64-bit build. The user can provide a remapping file specifying parts of mangled names that should be treated as equivalent (eg, std::__1 should be treated as equivalent to std::__cxx11), and profile data will be treated as applying to a particular function if its name is equivalent to the name of a function in the profile data under the provided equivalences. See the documentation change for a description of how this is configured. Remapping is supported for both sample-based profiling and instruction profiling. We do not support remapping indirect branch target information, but all other profile data should be remapped appropriately. Support is only added for the new pass manager. If someone wants to also add support for this for the old pass manager, doing so should be straightforward. llvm-svn: 344199
* Remove non-existant typeloc matchers from documentationStephen Kelly2018-10-092-110/+3
| | | | llvm-svn: 344023
* Regenerate AST Matcher docsStephen Kelly2018-10-091-7/+29
| | | | llvm-svn: 344022
* clang-format: better handle statement macrosFrancois Ferrand2018-10-021-0/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: Some macros are used in the body of function, and actually contain the trailing semicolon: they should thus be automatically followed by a new line, and not get merged with the next line. This is for example the case with Qt's Q_UNUSED macro: void foo(int a, int b) { Q_UNUSED(a) return b; } This patch deals with these cases by introducing a new option to specify list of statement macros. This re-uses the system already in place for foreach macros, to ensure there is no impact on performance. Reviewers: krasimir, djasper, klimek Reviewed By: krasimir Subscribers: acoomans, mgrang, alexfh, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D33440 llvm-svn: 343602
* Update CMakeLists.txt snippet so that example compilesStephen Kelly2018-10-011-0/+1
| | | | | | | | | | | | | | | | Summary: Previous to this the example didn't work out of the box, it seems some cmake config changed between when this was written and now. Author: Dan Zimmerman <daniel.zimmerman@me.com> Reviewers: modocache, steveire Reviewed By: steveire Subscribers: smeenai, steveire, cfe-commits Differential Revision: https://reviews.llvm.org/D52664 llvm-svn: 343530
* [analyzer] Add a testing facility for testing relationships between symbols.Artem Dergachev2018-09-251-0/+17
| | | | | | | | | | | | | | | | | | Tests introduced in r329780 was disabled in r342317 because these tests were accidentally testing dump infrastructure, when all they cared about was how symbols relate to each other. So when dump infrastructure changed, tests became annoying to maintain. Add a new feature to ExprInspection: clang_analyzer_denote() and clang_analyzer_explain(). The former adds a notation to a symbol, the latter expresses another symbol in terms of previously denoted symbols. It's currently a bit wonky - doesn't print parentheses and only supports denoting atomic symbols. But it's even more readable that way. Differential Revision: https://reviews.llvm.org/D52133 llvm-svn: 343048
* [AArch64] Support adding X[8-15,18] registers as CSRs.Tri Vo2018-09-251-0/+36
| | | | | | | | | | | | | | | | | | Summary: Making X[8-15,18] registers call-saved is used to support CONFIG_ARM64_LSE_ATOMICS in Linux kernel. Signed-off-by: Tri Vo <trong@android.com> Reviewers: srhines, nickdesaulniers, javed.absar Reviewed By: nickdesaulniers Subscribers: kristof.beyls, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D52399 llvm-svn: 342990
* [Modules] Add platform and environment features to requires clauseBruno Cardoso Lopes2018-09-181-1/+6
| | | | | | | | | | | | | Allows module map writers to add build requirements based on platform/os. This helps when target features and language dialects aren't enough to conditionalize building a module, among other things, it allow module maps for different platforms to live in the same file. rdar://problem/43909745 Differential Revision: https://reviews.llvm.org/D51910 llvm-svn: 342499
* [ASTMatchers] Let isArrow also support UnresolvedMemberExpr, ↵Shuai Wang2018-09-171-0/+61
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D52157 llvm-svn: 342407
* [AArch64] Support reserving x1-7 registers.Tri Vo2018-09-121-0/+28
| | | | | | | | | | | | | | Summary: Reserving registers x1-7 is used to support CONFIG_ARM64_LSE_ATOMICS in Linux kernel. This change adds support for reserving registers x1 through x7. Reviewers: javed.absar, efriedma, nickdesaulniers, srhines, phosek Reviewed By: nickdesaulniers Subscribers: manojgupta, jfb, cfe-commits, kristof.beyls Differential Revision: https://reviews.llvm.org/D48581 llvm-svn: 342100
* [Diagnostic] Fix a warning typo. NFC.Matt Davis2018-09-121-3/+3
| | | | | | s/aligment/alignment/ llvm-svn: 342068
* Introduce the VTable interleaving scheme to the CFI design documentationPeter Collingbourne2018-09-111-0/+148
| | | | | | | | | | | | | | Dimitar et. al. in [1] proposed a novel VTable layout scheme that enables efficient implementation of virtual call CFI. This patch adds an introduction of this scheme to the CFI design documentation. [1] Protecting C++ Dynamic Dispatch Through VTable Interleaving. Dimitar Bounov, Rami Gökhan Kıcı, Sorin Lerner. https://cseweb.ucsd.edu/~lerner/papers/ivtbl-ndss16.pdf Patch by Zhaomo Yang! Differential Revision: https://reviews.llvm.org/D50372 llvm-svn: 341989
* [clang-cl, PCH] Support for /Yc and /Yu without filename and #pragma hdrstopMike Rice2018-09-111-0/+5
| | | | | | | | | | | | | With clang-cl, when the user specifies /Yc or /Yu without a filename the compiler uses a #pragma hdrstop in the main source file to determine the end of the PCH. If a header is specified with /Yc or /Yu #pragma hdrstop has no effect. The optional #pragma hdrstop filename argument is not yet supported. Differential Revision: https://reviews.llvm.org/D51391 llvm-svn: 341963
* [ASTMatchers] add three matchers for dependent expressionsJonas Toth2018-09-111-0/+40
| | | | | | | | | | | | | | | | | | | Summary: The new matchers can be used to check if an expression is type-, value- or instantiation-dependent in a templated context. These matchers are used in a clang-tidy check and generally useful as the problem of unresolved templates occurs more often in clang-tidy and they provide an easy way to check for this issue. Reviewers: aaron.ballman, alexfh, klimek Reviewed By: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D51880 llvm-svn: 341958
* ReleaseNotes: update links to use httpsHans Wennborg2018-09-101-9/+9
| | | | llvm-svn: 341786
* [docs] Regenerate ClangCommandLineReference.rstVedant Kumar2018-08-231-96/+192
| | | | llvm-svn: 340559
* [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, ↵Shuai Wang2018-08-231-0/+28
| | | | | | | | | | | | CXXDependentScopeMemberExpr Reviewers: aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D50617 llvm-svn: 340547
OpenPOWER on IntegriCloud