Are there any automatic conversion tools for porting C ++ code to 64-bit?

I am exploring methods for transferring large (> 10 M lines) amounts of C ++ code to 64-bit. I have looked at static code analyzers and compiler flags, and now I am looking at macros or other tools that can make regular repeated changes.

I wrote some regular expressions to understand how well they work in practice, and as predicted, they are quite effective. However, it takes some time to create expressions, so I would like to see if there are any lists of such expressions or software tools that can automatically make changes.

The following lines are prototypical examples of code that needs to be matched and fixed. (To clarify, these lines are not intended to represent a single block of code, but instead, lines are drawn from different places.)

int i = 0; long objcount; int count = channels.count(ch); for (int k = 0; k < n; k++) { /*...*/ } 

The goal is not to completely reinstall the code to 64-bit, but instead to perform the first pass on the code to reduce the amount of code that needs to be manually verified. This is normal for some necessary changes that need to be missed, and it is probably normal for some incorrect changes, but they should be minimized.

Visual Studio is an IDE that will be used to work with conversion, so something that works well with VS is a plus. Cost is not a problem.

+5
source share
2 answers

Rexexps suffer from high false positive rate; by definition, a "regular expression" cannot parse a context-free langauge such as C ++. Moreover, regular expressions cannot account type information;

  fooT i=0; 

ok, for some typedef'd fooT? Finally, a regex cannot change code; you may consider Perl or SED (using regular expressions to modify changes), but you will get erroneous changes due to false positives for regular expressions. On a 10M SLOC, this can't be fun; A 5% error means that 50,000 lines of code are possible for manual correction.

You can consider the program conversion tool . Such engines work on language structures, and not in the text, and more complex versions know the areas, types and meaning of the symbol (for example, what is fooT, exactly?). They offer you the ability to write langauge- and context-sensitive templates and offer constructively correct code changes using the surface syntax of the target language. This allows you to reliably apply code changes to scale.

Our DMS Software Reengineering Toolkit with its C ++ Front End has been used to bulk modify large C ++ systems using syntax and type. (See Akers, R., Baxter, I., Mehlich, M., Ellis, B., Luecke, K., Case Study: Reconstructing C ++ Component Models Using Automatic Transformation of Programs, Information, and Software Technologies 49 (3 ): 275-291 2007.)

+1
source

What version of compiler are you using? Have you tried running the compiler with the / Wp 64 flag to detect portability to 64-bit issues?

From the MS website: "/ Wp64 detects 64-bit portability problems for types that are also marked with the __w64 keyword ./Wp64 is disabled by default in the 32-bit Visual C ++ compiler and enabled by default in the 64-bit Visual compiler C ++ ".

http://msdn.microsoft.com/en-us/library/yt4xw8fh%28v=vs.71%29.aspx

0
source

Source: https://habr.com/ru/post/891142/


All Articles