Custom Rule polyspace: typedef errors not being detected when custom types are being defined
조회 수: 3 (최근 30일)
이전 댓글 표시
Hello,
I'm having an issue with Polyspace custom rules, it doesn't detect when I try to do a typedef from a custom defined type to the type I want to define, but the regex works fine when I swap from the custom defined type to an int/char.
I have defined in a header file:
/* Platform_types.h*/
typedef signed char sint8;
typedef unsigned char uint8;
typedef signed short sint16;
typedef unsigned short uint16;
typedef signed long sint32;
typedef unsigned long uint32;
typedef sint8 SInt8;
typedef uint8 UInt8;
typedef sint16 SInt16;
typedef uint16 UInt16;
typedef sint32 SInt32;
typedef uint32 UInt32;
Then, I want to test my regex code for this type definitions:
/* Typesdef check */
/* Correct typedef */
typedef UInt8 Spi_ChannelType;
typedef UInt8 Spi_VariousWordsType;
typedef UInt8 I2c_ErrorReturnType;
/* Incorrect typedef */
typedef UInt8 Spi_CHANNEL_TYPE;
typedef UInt8 I2C_CHaNNelType;
typedef UInt8 CAN_ChannelType;
typedef UInt8 SpiChannelType;
typedef UInt16 t_channel;
typedef UInt8 Several__Underscores;
typedef UInt8 camel_CaseType;
The issue I have here, is that using the previously defined UIntX types, the incorrect typedef is not detected, but when I use the normal types (u/s int i.e.) All the incorrect typedefs are detected.
The typedef rules only work with int/float types on the left or am I missing something?
Thank you for your time.
댓글 수: 0
답변 (1개)
Anirban
2021년 7월 1일
편집: Anirban
2021년 7월 1일
I am assuming that you are using custom rules of group 3. I think, the way the checker works, it looks at each typedef of the form:
typedef type1 type2
and parses type1 to determine if the type is an integer type, a floating point type, a pointer, an array or a function pointer. The parsing happens before any type resolution. So, if type1 is itself a derived type, this parsing does not tell the checker what something like UInt8 means, and so the custom rules fail to apply.
I don't think you want the parsing to happen after type resolution either. That is, for instance, you do not want all typedef-s of unsigned char to follow your regex. You probably want only typedefs of UInt8 to follow your regex.
Depending on your exact needs, there might be workarounds. Please contact MathWorks Technical Support: https://www.mathworks.com/support/contact_us.html
참고 항목
카테고리
Help Center 및 File Exchange에서 Run Settings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!