예제 #1
0
def register_our_attributes():
    gcc.register_attribute('claims_mutex',
                           1, 1,
                           False, False, False,
                           attribute_callback_for_claims_mutex)
    gcc.register_attribute('releases_mutex',
                           1, 1,
                           False, False, False,
                           attribute_callback_for_releases_mutex)
예제 #2
0
def register_our_attributes():
    gcc.register_attribute('claims_mutex',
                           1, 1,
                           False, False, False,
                           attribute_callback_for_claims_mutex)
    gcc.define_macro('WITH_ATTRIBUTE_CLAIMS_MUTEX')

    gcc.register_attribute('releases_mutex',
                           1, 1,
                           False, False, False,
                           attribute_callback_for_releases_mutex)
    gcc.define_macro('WITH_ATTRIBUTE_RELEASES_MUTEX')
예제 #3
0
def register_our_attributes():
    gcc.register_attribute('custom_attribute_without_args', 0, 0, False, False,
                           False, my_attribute_callback_A)
    gcc.register_attribute('custom_attribute_with_one_arg', 1, 1, False, False,
                           False, my_attribute_callback_B)
    gcc.register_attribute('custom_attribute_with_one_or_two_args', 1, 2,
                           False, False, False, my_attribute_callback_C)
예제 #4
0
def register_our_attributes():
    gcc.register_attribute('custom_attribute_without_args',
                           0, 0,
                           False, False, False,
                           my_attribute_callback_A)
    gcc.register_attribute('custom_attribute_with_one_arg',
                           1, 1,
                           False, False, False,
                           my_attribute_callback_B)
    gcc.register_attribute('custom_attribute_with_one_or_two_args',
                           1, 2,
                           False, False, False,
                           my_attribute_callback_C)
예제 #5
0
def register_our_attributes():
    # Callback, called by the gcc.PLUGIN_ATTRIBUTES event

    # Handler for __attribute__((cpychecker_returns_borrowed_ref))
    # and #ifdef WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE
    def attribute_callback_for_returns_borrowed_ref(*args):
        if 0:
            print('attribute_callback_for_returns_borrowed_ref(%r)' % args)
        check_isinstance(args[0], gcc.FunctionDecl)
        fnname = args[0].name
        fnnames_returning_borrowed_refs.add(fnname)

    gcc.register_attribute('cpychecker_returns_borrowed_ref',
                           0, 0,
                           False, False, False,
                           attribute_callback_for_returns_borrowed_ref)
    gcc.define_macro('WITH_CPYCHECKER_RETURNS_BORROWED_REF_ATTRIBUTE')

    # Handler for __attribute__((cpychecker_steals_reference_to_arg(n)))
    # and #ifdef WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE
    def attribute_callback_for_steals_reference_to_arg(*args):
        if 0:
            print('attribute_callback_for_steals_reference_to_arg(%r)' % (args, ))
        check_isinstance(args[0], gcc.FunctionDecl)
        check_isinstance(args[1], gcc.IntegerCst)
        fnname = args[0].name
        argindex = int(args[1].constant)

        if fnname in stolen_refs_by_fnname:
            stolen_refs_by_fnname[fnname].add(argindex)
        else:
            stolen_refs_by_fnname[fnname] = set([argindex])

    gcc.register_attribute('cpychecker_steals_reference_to_arg',
                           1, 1,
                           False, False, False,
                           attribute_callback_for_steals_reference_to_arg)
    gcc.define_macro('WITH_CPYCHECKER_STEALS_REFERENCE_TO_ARG_ATTRIBUTE')

    # Handler for __attribute__((cpychecker_type_object_for_struct(type)))
    # and #ifdef WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE
    def attribute_callback_type_object_for_typedef(*args):
        if 0:
            print('attribute_callback_type_object_for_typedef(%r)' % (args, ))
        check_isinstance(args[0], gcc.VarDecl)
        check_isinstance(args[1], gcc.StringCst)
        typedef_name = args[1].constant
        register_type_object(args[0], typedef_name)

    gcc.register_attribute('cpychecker_type_object_for_typedef',
                           1, 1,
                           False, False, False,
                           attribute_callback_type_object_for_typedef)
    gcc.define_macro('WITH_CPYCHECKER_TYPE_OBJECT_FOR_TYPEDEF_ATTRIBUTE')

    # Handler for __attribute__((cpychecker_sets_exception))
    # and #ifdef WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE
    def attribute_callback_for_sets_exception(*args):
        if 0:
            print('attribute_callback_for_sets_exception(%r)' % args)
        check_isinstance(args[0], gcc.FunctionDecl)
        fnname = args[0].name
        fnnames_setting_exception.add(fnname)

    gcc.register_attribute('cpychecker_sets_exception',
                           0, 0,
                           False, False, False,
                           attribute_callback_for_sets_exception)
    gcc.define_macro('WITH_CPYCHECKER_SETS_EXCEPTION_ATTRIBUTE')

    # Handler for __attribute__((cpychecker_negative_result_sets_exception))
    # and #ifdef WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE
    def attribute_callback_for_negative_result_sets_exception(*args):
        if 0:
            print('attribute_callback_for_negative_result_sets_exception(%r)' % args)
        check_isinstance(args[0], gcc.FunctionDecl)
        fnname = args[0].name
        fnnames_setting_exception_on_negative_result.add(fnname)

    gcc.register_attribute('cpychecker_negative_result_sets_exception',
                           0, 0,
                           False, False, False,
                           attribute_callback_for_negative_result_sets_exception)
    gcc.define_macro('WITH_CPYCHECKER_NEGATIVE_RESULT_SETS_EXCEPTION_ATTRIBUTE')
예제 #6
0
def register_our_attributes():
    gcc.register_attribute('claims_mutex', 1, 1, False, False, False,
                           attribute_callback_for_claims_mutex)
    gcc.register_attribute('releases_mutex', 1, 1, False, False, False,
                           attribute_callback_for_releases_mutex)
예제 #7
0
def register_attributes():
    gcc.register_attribute("output_args", 1, -1, False, False, False,
                           output_args_cb)
    gcc.define_macro("PCMK__WITH_ATTRIBUTE_OUTPUT_ARGS")