On Oct 29, 2012, at 17:48 , Anna Zaks <[email protected]> wrote:

> 
> On Oct 29, 2012, at 4:08 PM, Jordan Rose wrote:
> 
>> 
>> On Oct 29, 2012, at 15:51 , Anna Zaks <[email protected]> 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.
> will commit later with the macro rename

Also, I don't think CheckerContext is the right file for this, since it's 
perfectly usable by Core. (DynamicDispatchBifurcationMap?) ProgramStateTrait.h?


>>> +#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.)
>> 
> That right! Thanks for catching. 
>> 
>>> +  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.
>> 
>>> +    }; \
>>> +  } \
>>> +  }
>>> +
>> 
>> 
>> 
> 


_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to