summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [analyzer] Do not run visitors until the fixpoint, run only once.George Karpenkov2018-06-261-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In the current implementation, we run visitors until the fixed point is reached. That is, if a visitor adds another visitor, the currently processed path is destroyed, all diagnostics is discarded, and it is regenerated again, until it's no longer modified. This pattern has a few negative implications: - This loop does not even guarantee to terminate. E.g. just imagine two visitors bouncing a diagnostics around. - Performance-wise, e.g. for sqlite3 all visitors are being re-run at least 10 times for some bugs. We have already seen a few reports where it leads to timeouts. - If we want to add more computationally intense visitors, this will become worse. - From architectural standpoint, the current layout requires copying visitors, which is conceptually wrong, and can be annoying (e.g. no unique_ptr on visitors allowed). The proposed change is a much simpler architecture: the outer loop processes nodes upwards, and whenever the visitor is added it only processes current nodes and above, thus guaranteeing termination. Differential Revision: https://reviews.llvm.org/D47856 llvm-svn: 335666
* Fix typos in clangAlexander Kornienko2018-04-061-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Found via codespell -q 3 -I ../clang-whitelist.txt Where whitelist consists of: archtype cas classs checkk compres definit frome iff inteval ith lod methode nd optin ot pres statics te thru Patch by luzpaz! (This is a subset of D44188 that applies cleanly with a few files that have dubious fixes reverted.) Differential revision: https://reviews.llvm.org/D44188 llvm-svn: 329399
* [analyzer] introduce getSVal(Stmt *) helper on ExplodedNode, make sure the ↵George Karpenkov2018-01-171-2/+1
| | | | | | | | | | | | | | | | | | helper is used consistently In most cases using `N->getState()->getSVal(E, N->getLocationContext())` is ugly, verbose, and also opens up more surface area for bugs if an inconsistent location context is used. This patch introduces a helper on an exploded node, and ensures consistent usage of either `ExplodedNode::getSVal` or `CheckContext::getSVal` across the codebase. As a result, a large number of redundant lines is removed. Differential Revision: https://reviews.llvm.org/D42155 llvm-svn: 322753
* [analyzer] Add annotation for functions taking user-facing stringsErik Verbruggen2017-07-141-10/+59
| | | | | | | | | | | | | | | | There was already a returns_localized_nsstring annotation to indicate that the return value could be passed to UIKit methods that would display them. However, those UIKit methods were hard-coded, and it was not possible to indicate that other classes/methods in a code-base would do the same. The takes_localized_nsstring annotation can be put on function parameters and selector parameters to indicate that those will also show the string to the user. Differential Revision: https://reviews.llvm.org/D35186 llvm-svn: 308012
* [analyzer] LocalizationChecker: Support new localizable APIs.Artem Dergachev2017-06-211-0/+43
| | | | | | | | | | | | Add support for new methods that were added in macOS High Sierra & iOS 11 and require a localized string. Patch by Kulpreet Chilana! rdar://problem/32795210 Differential Revision: https://reviews.llvm.org/D34266 llvm-svn: 305896
* Migrate PathDiagnosticPiece to std::shared_ptrDavid Blaikie2017-01-051-8/+8
| | | | | | | Simplifies and makes explicit the memory ownership model rather than implicitly passing/acquiring ownership. llvm-svn: 291143
* [analyzer] Use lazily created buffer in EmptyLocalizationContextCheckerDevin Coughlin2016-08-301-1/+8
| | | | | | | | | | | Fix a crash when relexing the underlying memory buffer to find incorrect arguments to NSLocalizedString(). With precompiled headers, the raw buffer may be NULL. Instead, use the source manager to get the buffer, which will lazily create the buffer for precompiled headers. rdar://problem/27429091 llvm-svn: 280174
* [analyzer] Update APIs taking user-facing strings.Devin Coughlin2016-07-301-6/+22
| | | | | | | | | | | Add new APIs that require localized strings and remove two APIs that were incorrectly marked as requiring a user-facing string. A patch by Kulpreet Chilana! Differential Revision: https://reviews.llvm.org/D22926 llvm-svn: 277273
* [NFC] Header cleanupMehdi Amini2016-07-181-4/+3
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* [analyzer] Add path note for localizability checker.Devin Coughlin2016-04-281-0/+64
| | | | | | | | | Add a path note indicating the location of the non-localized string literal in NonLocalizedStringChecker. rdar://problem/25981525 llvm-svn: 267924
* Simplify users of StringRef::{l,r}trim (clang) (NFC)Vedant Kumar2016-02-161-1/+1
| | | | | | | r260925 introduced a version of the *trim methods which is preferable when trimming a single kind of character. Update all users in clang. llvm-svn: 260927
* [analyzer] Suppress localization diagnostics in debug classes and methods.Devin Coughlin2016-02-051-0/+35
| | | | | | | If the class or method name case-insensitively contains the term "debug", suppress warnings about string constants flowing to user-facing UI APIs. llvm-svn: 259875
* [analyzer] Add 'optin' checker package and move localizability checkers into it.Devin Coughlin2015-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | This commit creates a new 'optin' top-level checker package and moves several of the localizability checkers into it. This package is for checkers that are not alpha and that would normally be on by default but where the driver does not have enough information to determine when they are applicable. The localizability checkers fit this criterion because the driver cannot determine whether a project is localized or not -- this is best determined at the IDE or build-system level. This new package is *not* intended for checkers that are too noisy to be on by default. The hierarchy under 'optin' mirrors that in 'alpha': checkers under 'optin' should be organized in the hierarchy they would have had if they were truly top level (e.g., optin.osx.cocoa.MyOptInChecker). Differential Revision: http://reviews.llvm.org/D14303 llvm-svn: 252080
* [analyzer] Improve localizability checks for iOS / OS X.Devin Coughlin2015-09-231-97/+703
| | | | | | | | | | | | | | | | | | | | Various improvements to the localization checker: * Adjusted copy to be consistent with diagnostic text in other Apple API checkers. * Added in ~150 UIKit / AppKit methods that require localized strings in UnlocalizedStringsChecker. * UnlocalizedStringChecker now checks for UI methods up the class hierarchy and UI methods that conform for a certain Objective-C protocol. * Added in alpha version of PluralMisuseChecker and some regression tests. False positives are still not ideal. (This is the second attempt, with the memory issues on Linux resolved.) A patch by Kulpreet Chilana! Differential Revision: http://reviews.llvm.org/D12417 llvm-svn: 248432
* Revert "[analyzer] Improve localizability checks for iOS / OS X."Devin Coughlin2015-09-231-703/+97
| | | | | | This reverts commit r248350. The pluralization checks are failing on some bots. llvm-svn: 248351
* [analyzer] Improve localizability checks for iOS / OS X.Devin Coughlin2015-09-221-97/+703
| | | | | | | | | | | | | | | | | | Various improvements to the localization checker: * Adjusted copy to be consistent with diagnostic text in other Apple API checkers. * Added in ~150 UIKit / AppKit methods that require localized strings in UnlocalizedStringsChecker. * UnlocalizedStringChecker now checks for UI methods up the class hierarchy and UI methods that conform for a certain Objective-C protocol. * Added in alpha version of PluralMisuseChecker and some regression tests. False positives are still not ideal. A patch by Kulpreet Chilana! Differential Revision: http://reviews.llvm.org/D12417 llvm-svn: 248350
* Add missing newline.Ted Kremenek2015-08-261-1/+1
| | | | llvm-svn: 246003
* [analyzer] Add checkers for OS X / iOS localizability issuesAnna Zaks2015-08-141-0/+595
| | | | | | | | | | | | | | | Add checkers that detect code-level localizability issues for OS X / iOS: - A path sensitive checker that warns about uses of non-localized NSStrings passed to UI methods expecting localized strings. - A syntax checker that warns against not including a comment in NSLocalizedString macros. A patch by Kulpreet Chilana! (This is the second attempt with the compilation issue on Windows and the random test failures resolved.) llvm-svn: 245093
* Revert "[analyzer] Add checkers for OS X / iOS localizability issues"Anna Zaks2015-08-081-559/+0
| | | | | | | | This reverts commit fc885033a30b6e30ccf82398ae7c30e646727b10. Revert all localization checker commits until the proper fix is implemented. llvm-svn: 244394
* Revert "[analyzer] Fixup to r244389 to make this build on windows."Anna Zaks2015-08-081-1/+1
| | | | | | | | This reverts commit 57a46a75b408245cf4154a838fe13ad702065745. Revert all localization checker commits until the proper fix is implemented. llvm-svn: 244393
* [analyzer] Fixup to r244389 to make this build on windows.Anna Zaks2015-08-081-1/+1
| | | | llvm-svn: 244390
* [analyzer] Add checkers for OS X / iOS localizability issuesAnna Zaks2015-08-081-0/+559
Add checkers that detect code-level localizability issues for OS X / iOS: - A path sensitive checker that warns about uses of non-localized NSStrings passed to UI methods expecting localized strings. - A syntax checker that warns against not including a comment in NSLocalizedString macros. A patch by Kulpreet Chilana! llvm-svn: 244389
OpenPOWER on IntegriCloud