[cfe-commits] r166975 - in /cfe/trunk: include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h lib/StaticAnalyzer/Checkers/StreamChecker.cpp
Jordan Rose
jordan_rose at apple.com
Mon Oct 29 16:08:16 PDT 2012
On Oct 29, 2012, at 15:51 , Anna Zaks <ganna at apple.com> wrote:
> Author: zaks
> Date: Mon Oct 29 17:51:44 2012
> New Revision: 166975
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166975&view=rev
> Log:
> [analyzer] Add checker helpers to CheckerContext.
>
> - Adding Immutable Map to GDM and getIdentifierInfo helper method.
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
> cfe/trunk/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=166975&r1=166974&r2=166975&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Mon Oct 29 17:51:44 2012
> @@ -16,6 +16,21 @@
> #define LLVM_CLANG_SA_CORE_PATHSENSITIVE_CHECKERCONTEXT
>
> #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
> +#include "llvm/ADT/ImmutableMap.h"
> +
> +// Declare an immutable map suitable for placement into program states's GDM.
Doxygen comment? Also, it'd be nice to mention that this must not be used inside any namespaces.
> +#define REGISTER_MAP_WITH_GDM(Map, Key, Value) \
> + typedef llvm::ImmutableMap<Key, Value> Map; \
This is not correct; two maps with the same keys and values will share a GDM entry this way. This could easily happen with maps to bool, for example. No matter what the template argument for ProgramStateTrait must be a unique type. (…which should then probably be in an anonymous namespace.)
> + namespace clang { \
> + namespace ento { \
> + template <> \
> + struct ProgramStateTrait<Map> \
> + : public ProgramStatePartialTrait<Map> { \
> + static void *GDMIndex() { static int Index; return &Index; } \
I think ideally we'd rewrite the accessor in ProgramState to be templated here, like how CheckerManager generates unique tags for checkers. That way even custom implementers won't have to include the GDMIndex boilerplate.
> + }; \
> + } \
> + }
> +
More information about the cfe-commits
mailing list