aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/AnalysisConsumer.cpp
AgeCommit message (Collapse)Author
2010-06-15Break Frontend's dependency on Rewrite, Checker and CodeGen in shared ↵Daniel Dunbar
library configuration Currently, all AST consumers are located in the Frontend library, meaning that in a shared library configuration, Frontend has a dependency on Rewrite, Checker and CodeGen. This is suboptimal for clients which only wish to make use of the frontend. CodeGen in particular introduces a large number of unwanted dependencies. This patch breaks the dependency by moving all AST consumers with dependencies on Rewrite, Checker and/or CodeGen to their respective libraries. The patch therefore introduces dependencies in the other direction (i.e. from Rewrite, Checker and CodeGen to Frontend). After applying this patch, Clang builds correctly using CMake and shared libraries ("cmake -DBUILD_SHARED_LIBS=ON"). N.B. This patch includes file renames which are indicated in the patch body. Changes in this revision of the patch: - Fixed some copy-paste mistakes in the header files - Modified certain aspects of the coding to comply with the LLVM Coding Standards git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106010 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-15Change AnalysisConsumer to analyze functions created by instantiantiating a ↵Ted Kremenek
macro. Fixes PR 7361. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105984 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-18Add option '-analyzer-max-loop', which specifies the maximum Zhongxing Xu
number of times the analyzer will go through a loop. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@104007 91177308-0d34-0410-b5e6-96231b3b80d8
2010-05-06Make -analyzer-inline-call not a separate analysis. Instead it's a boolean Zhongxing Xu
flag now, and can be used with other analyses. Only turned it on for C++ methods for now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103160 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Don't perform AnalysisBasedWarnings in Sema or run the static analyzer when aTed Kremenek
fatal error has occurred. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102778 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Remove unused trait.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102690 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-30Refactor the AnalysisConsumer to analyze functions after the whole Zhongxing Xu
translation unit is parsed. This enables us to inline some calls when still analyzing one function at a time. Actions are classified into Function, CXXMethod, ObjCMethod, ObjCImplementation. This does not hurt performance much. The analysis time for sqlite3.c: before: real 17m52.440s user 17m49.460s sys 0m2.010s after: real 18m0.500s user 17m56.900s sys 0m2.330s DisplayProgress option is broken now. -inine-call action is removed. It will be reenabled in another form, perhaps as an indenpendant option. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102689 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-17Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer
users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101632 91177308-0d34-0410-b5e6-96231b3b80d8
2010-04-13Add a cc1 option to specify the max number of nodes the analyzer can explore.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14Change LLVMConventionsChecker to accept an entire translation unit insteadTed Kremenek
of operating on each code decl. This exposes two flaws in AnalysisConsumer that should eventually be fixed: (1) It is not possible to associate multiple "actions" with a single command line argument. This will require the notion of an "analysis" group, and possibly tablegen support. (although eventually we want to support dynamically loading analyses as well) (2) AnalysisConsumer may not actually be scanning the declarations in namespaces. We'll experiment first in LLVMConventionsChecker before changing the behavior in AnalysisConsumer. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96183 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14Rework translation unit actions to actually take an entire translation unitTed Kremenek
as imput. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96182 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14Add new static analyzer for checking LLVM coding conventions: ↵Ted Kremenek
-analyzer-check-llvm-conventions Currently these checks are intended to be largely syntactical, but may get more sophisticated over time. As an initial foray into this brave new world, emit a static analyzer warning when binding a temporary 'std::string' to an 'llvm::StringRef' where the lifetime of the 'std::string' does not outlive the 'llvm::StringRef'. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96147 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-14Two changes to AnalysisConsumer::HandleTopLevelSingleDecl():Ted Kremenek
(1) Since CXXMethodDecl subclasses FunctionDecl (and CXXDestructorDecl and CXXConversion subclass CXXMethodDecl), refactor switch statement to handle them all in one spot. (2) Use 'DeclarationName::getAsString()' to handle all functions that don't have simple identifiers (fixing a null dereference when scanning for specific functions). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@96146 91177308-0d34-0410-b5e6-96231b3b80d8
2010-02-05Rename -cc1 option '-checker-cfref' to '-analyzer-check-objc-mem'.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95348 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-26Move 'LocalCheckers.h' to the 'Checkers' subdirectory.Ted Kremenek
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94609 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25Move BugReporter.h, PathDiagnostic.h, and BugType.h to ↵Ted Kremenek
'include/Checker/BugReporter' git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94428 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-25Split libAnalysis into two libraries: libAnalysis and libChecker.Ted Kremenek
(1) libAnalysis is a generic analysis library that can be used by Sema. It defines the CFG, basic dataflow analysis primitives, and inexpensive flow-sensitive analyses (e.g. LiveVariables). (2) libChecker contains the guts of the static analyzer, incuding the path-sensitive analysis engine and domain-specific checks. Now any clients that want to use the frontend to build their own tools don't need to link in the entire static analyzer. This change exposes various obvious cleanups that can be made to the layout of files and headers in libChecker. More changes pending. :) This change also exposed a layering violation between AnalysisContext and MemRegion. BlockInvocationContext shouldn't explicitly know about BlockDataRegions. For now I've removed the BlockDataRegion* from BlockInvocationContext (removing context-sensitivity; although this wasn't used yet). We need to have a better way to extend BlockInvocationContext (and any LocationContext) to add context-sensitivty. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94406 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Also handle CXXConstructor, CXXDestructor and CXXConversion in CFGMike Stump
printing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93968 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20Use the llvm coding convention for indentation for switch.Mike Stump
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93966 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05Remove references to 'Checker' and 'GRTransferFuncs' fromTed Kremenek
GRStateManager. Having these references was an abstraction violation, as they really should only be known about GRExprEngine. This change required adding a new 'ProcessAssume' callback in GRSubEngine. GRExprEngine implements this callback by calling 'EvalAssume' on all registered Checker objects as well as the registered GRTransferFunc object. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92549 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31Let constraint manager inform checkers that some assumption logic has happend.Zhongxing Xu
Add new states for symbolic regions tracked by malloc checker. This enables us to do malloc checking more accurately. See test case. Based on Lei Zhang's patch and discussion. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92342 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30Remove an duplicated #include.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92306 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23Register call inliner as the last checker.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91992 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23Migrate the call inliner to the Checker interface.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16Expose C++ methods to GRExprEngine.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91506 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15Add comments.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91430 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15Remove displayProgress parameter.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91429 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-12We should only scan for nested blocks if we are analyzing the body of a ↵Ted Kremenek
function/method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91196 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-09Fix crash in DisplayFunction(). ObjCInterfaceDecls can also get passed to ↵Ted Kremenek
this function, but we don't want to display them. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90944 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-07Add clang-cc option '-analyzer-opt-analyze-nested-blocks' to treat block ↵Ted Kremenek
literals as an entry point for analyzer checks. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90810 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-28Remove VISIBILITY_HIDDEN from anonymous namespaces in libFrontend.Benjamin Kramer
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90033 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25Call GRExprEngine::setTransferFunctions() after registering all Checkers. ↵Ted Kremenek
This allows GRTransferFuncs::RegisterChecks() to always be called after all checkers have been registered. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89887 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25Consolidate logic in ActionInlineCall by having it call ActionGRExprEngine ↵Ted Kremenek
instead of replicating most of its logic (and missing pieces). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89886 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25Make RegisterInternalChecks() part of GRExprEngine's private implementation ↵Ted Kremenek
by making it a static function within GRExprEngine.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89884 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-25Register internal checks with GRExprEngine when it is constructed, not ↵Ted Kremenek
manually in AnalysisConsumer.cpp. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89883 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-17Silence some warnings produced by Clang, and add a missing headerDouglas Gregor
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89051 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13Add clang-cc option "--analyzer-experimental-internal-checks". ThisTed Kremenek
option enables new "internal" checks that will eventually be turned on by default but still require broader testing. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88671 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-13Add clang-cc option "-analyzer-experimental-checks" to enable experimental ↵Ted Kremenek
path-sensitive checks. The idea is to separate "barely working" or "skunkworks" checks from ones that should always run. Later we need more fine-grain checker control. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@87053 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11Move the ManagerRegistry to the Analysis library to resolve the layering ↵Chandler Carruth
violation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86863 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-11Fix display of "ANALYZE" statements in AnalysisConsumer by correctly ↵Ted Kremenek
resetting the flag indicating that the current Decl* has not yet been displayed. Also move this out of AnalysisManager, since AnalysisManager should not handle text output to the user. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86812 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-08Add a checker for CWE-467: Use of sizeof() on a Pointer Type.Zhongxing Xu
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86464 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05Convert CreateAnalysisConsumer and friends to just take a const ↵Daniel Dunbar
Preprocessor&, and simplify. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86112 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-05Acting on Daniel's nagging, remove PathDiagnosticClientFactory() andTed Kremenek
migrate work in the destructors of PathDiagnosticClients from their destructors to FlushReports(). The destructors now currently call FlushReports(); this will be fixed in a subsequent patch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86108 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-04Kill PreprocessorFactory, which was both morally repugnant and totally unused.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86076 91177308-0d34-0410-b5e6-96231b3b80d8
2009-11-02Remove unused header.Daniel Dunbar
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85828 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-20Add destructor and cleanup code to LocationContext (fixing some leaks). ↵Ted Kremenek
Along the way, have AnalysisManager periodically cleanup its AnalysisContextManager and LocationContextManager objects, as they don't need to forever retain all the CFGs ever created when analyzing a file. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84684 91177308-0d34-0410-b5e6-96231b3b80d8
2009-10-18PR5218: Replace IdentifierInfo::getName with StringRef version, now that clientsDaniel Dunbar
are updated. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@84447 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-26Hoist some branches in AnalysisManager::HandleTranslationUnit so weTed Kremenek
avoid scanning for an "entry point" FunctionDecl if we (a) have no translation unit actions and (b) no entry point function has been specified. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82846 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18Fix regression introduced by r82198 that caused functions/methods with ↵Ted Kremenek
invalid CFGs to get analyzed. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82297 91177308-0d34-0410-b5e6-96231b3b80d8
2009-09-18Introduce caching of diagnostics in BugReporter. This provides extraTed Kremenek
pruning of diagnostics that may be emitted multiple times. This is accomplished by adding FoldingSet profiling support to PathDiagnostic, and then having BugReporter record what diagnostics have been issued. This was motived to a serious bug introduced by moving the 'divide-by-zero' checking outside of GRExprEngine into a separate 'Checker' class. When analyzing code using the '-fobjc-gc' option, a given function would be analyzed twice, but the second time various "internal checks" would be disabled to avoid emitting multiple diagnostics (e.g., "null dereference") for the same issue. The problem is that such checks also effect path pruning and don't just emit diagnostics. This resulted in an assertion failure involving a real divide-by-zero in some analyzed code where we would get an assertion failure in APInt because the 'DivZero' check was disabled and didn't prune the logic that resulted in the divide-by-zero in the analyzer. The implemented solution is somewhat of a hack, and may not perform extremely well. This will need to be cleaned up over time. As a regression test, 'misc-ps.m' has been modified so that its tests are run using -fobjc-gc to test this diagnostic pruning behavior. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82198 91177308-0d34-0410-b5e6-96231b3b80d8