IP Library Granted Patent US 11,941,382
Granted Patent B2
US 11,941,382 · App. 17/665,832 · Granted Mar 26, 2024

User customizable compiler attributes for code checking

Inventor: Ulrich Drepper (Grasbrunn, DE)
Assignee: Red Hat, Inc.
G06F8/437
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 11,941,382
App. No.
17/665,832
Granted
Mar 26, 2024
Kind
B2
Abstract

Disclosed herein is technology to use customized compiler attributes to check source code. An example method may include: accessing, by a processing device executing a compiler, a source code that comprises a compiler attribute associated with a programming construct, wherein the compiler attribute is defined in the source code; executing, by the processing device, a function of the compiler to check the programming construct at a location in the source code, wherein the function checks the programming construct by evaluating the compiler attribute associated with the programming construct; determining, by the processing device executing the compiler, whether to generate a message indicating a status of the check; and generating, by the processing device executing the compiler, object code based on the source code that comprises the compiler attribute.

Claims (40)

1. A method comprising:

accessing, by a processing device executing a compiler, a source code that comprises a customized compiler attribute;

detecting, by the processing device, the customized compiler attribute;

deriving, by the processing device, a definition and logic associated with the customized compiler attribute from source code;

executing, by the processing device executing the compiler, a function of the compiler to check a targeted programming construct at a location in the source code using the derived logic associated with the customized compiler attribute;

determining, by the processing device executing the compiler, whether to generate a message indicating a status of the check; and

generating, by the processing device executing the compiler, object code based on the source code.

2. The method of claim 1 , wherein the customized compiler attribute is defined in view of text added by an author of the source code into the source code, wherein the text comprises a call to the predefined compiler function and one or more user defined values created by the author, wherein the user defined values comprise a user defined attribute name.

3. The method of claim 1 , wherein the customized compiler attribute is defined by a first author of the source code, and wherein the function comprises a built-in compiler function that evaluates the customized compiler attribute at the location selected by a second author.

4. The method of claim 1 , wherein the customized compiler attribute and the function of the compiler are used at compile time to detect a logic error that would occur at a runtime of the object code.

5. The method of claim 1 , wherein the customized compiler attribute and a call to the function evaluating the customized compiler attribute are present in the source code and are absent from the object code.

6. The method of claim 1 , further comprising, updating the source code to add a plurality of compiler attributes and a plurality of calls to functions that evaluate the compiler attributes, wherein the addition has no effect on new object code generated from the updated source code and the new object code is a duplicate of the object code that was previously generated.

7. The method of claim 1 , wherein the source code comprises a first portion corresponding to an application and a second portion corresponding to a kernel, wherein the first portion is updated by a first author to assign the customized compiler attribute to a variable and the second portion is updated by a second author to include a call to the function of the compiler that checks the variable.

8. The method of claim 1 , wherein the programming construct comprises a descriptor variable and the compiler attribute indicates that a target type of the descriptor variable comprises a file, a TCP socket, a UPD socket, or a pipe, and wherein the function of the compiler checks that the target type of the descriptor variable matches an input type for a kernel function.

9. A system comprising:

a memory; and

a processing device communicably coupled to the memory, the processing device to:

access a source code that comprises a customized compiler attribute;

detect, by the processing device, the customized compiler attribute;

derive, by the processing device, a definition and logic associated with the customized compiler attribute from source code;

execute a function of a compiler to check a targeted programming construct at a location in the source code using the derived logic associated with the customized compiler attribute;

determining whether to generate a message indicating a status of the check; and

generating object code based on the source code.

10. The system of claim 9 , wherein the customized compiler attribute is defined in view of text added by an author of the source code into the source code, wherein the text comprises a call to the predefined compiler function and one or more user defined values created by the author, wherein the user defined values comprise a user defined attribute name.

11. The system of claim 9 , wherein the customized compiler attribute is defined by a first author of the source code, and wherein the function comprises a built-in compiler function that evaluates the customized compiler attribute at the location selected by a second author.

12. The system of claim 9 , wherein the customized compiler attribute and the function of the compiler are used at compile time to detect a logic error that would occur at a runtime of the object code.

13. The system of claim 9 , wherein the customized compiler attribute and a call to the function evaluating the customized compiler attribute are present in the source code and are absent from the object code.

14. The system of claim 9 , wherein the processing device is further to update the source code to add a plurality of compiler attributes and a plurality of calls to functions that evaluate the compiler attributes, wherein the addition has no effect on new object code generated from the updated source code and the new object code is a duplicate of the object code that was previously generated.

15. The system of claim 9 , wherein the source code comprises a first portion corresponding to an application and a second portion corresponding to a kernel, wherein the first portion is updated by a first author to assign the customized compiler attribute to a variable and the second portion is updated by a second author to include a call to the function of the compiler that checks the variable.

16. The system of claim 9 , wherein the programming construct comprises a descriptor variable and the customized compiler attribute indicates that a target type of the descriptor variable comprises a file, a TCP socket, a UPD socket, or a pipe, and wherein the function of the compiler checks that the target type of the descriptor variable matches an input type for a kernel function.

17. A non-transitory machine-readable storage medium storing instructions which, when executed, cause a processing device to perform operations comprising:

accessing a source code that comprises a customized compiler attribute;

detecting, by the processing device, the customized compiler attribute;

deriving, by the processing device, a definition and logic associated with the customized compiler attribute from source code;

executing a function of a compiler to check a targeted programming construct at a location in the source code using the derived logic associated with the customized compiler attribute;

determining whether to generate a message indicating a status of the check; and

generating object code based on the source code.

18. The non-transitory machine-readable storage medium of claim 17 , wherein the customized compiler attribute is defined in view of text added by an author of the source code into the source code, wherein the text comprises a call to the predefined compiler function and one or more user defined values created by the author, wherein the user defined values comprise a user defined attribute name.

19. The non-transitory machine-readable storage medium of claim 17 , wherein the customized compiler attribute is defined by a first author of the source code, and wherein the function comprises a built-in compiler function that evaluates the customized compiler attribute at the location selected by a second author.

20. The non-transitory machine-readable storage medium of claim 17 , wherein the customized compiler attribute and the function of the compiler are used at compile time to detect a logic error that would occur at a runtime of the object code.

Assignments (2)
CHANGE OF NAME Recorded Mar 3, 2026
From: RED HAT, INC.
To: RED HAT, LLC
Reel/Frame 074913/0759 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Feb 8, 2022
From: DREPPER, ULRICH
To: RED HAT, INC.
Reel/Frame 058930/0356 →
Continuity (1)
Related Publication 20230251837A1 · Aug 10, 2023