• Top
    • Documentation
    • Books
    • Boolean-reasoning
    • Projects
      • Apt
      • Zfc
      • Acre
      • Milawa
      • Smtlink
      • Abnf
      • Vwsim
      • Isar
      • Wp-gen
      • Dimacs-reader
      • Pfcs
      • Legacy-defrstobj
      • Proof-checker-array
      • Soft
      • C
        • Syntax-for-tools
        • Atc
        • Language
        • Representation
        • Transformation-tools
          • Simpadd0
          • Deftrans
          • Splitgso
          • Constant-propagation
          • Split-fn
          • Copy-fn
            • Copy-fn-extdecl
            • Copy-fn-filepath-transunit-map
            • Rename-fn-filepath-transunit-map
            • Copy-fn-fundef
            • Rename-fn-transunit-ensemble
            • Copy-fn-transunit-ensemble
            • Copy-fn-extdecl-list
            • Rename-fn-ident-list
            • Rename-fn-fundef
            • Rename-fn-extdecl-list
            • Rename-fn-extdecl
            • Copy-fn-transunit
            • Rename-fn-transunit
            • Rename-fn-ident
            • Rename-fn-const
            • Rename-fn-funcall-fun
          • Specialize
          • Split-all-gso
          • Rename
          • Utilities
        • Insertion-sort
        • Pack
      • Farray
      • Rp-rewriter
      • Instant-runoff-voting
      • Imp-language
      • Sidekick
      • Leftist-trees
      • Java
      • Taspi
      • Bitcoin
      • Riscv
      • Des
      • Ethereum
      • X86isa
      • Sha-2
      • Yul
      • Zcash
      • Proof-checker-itp13
      • Regex
      • ACL2-programming-language
      • Json
      • Jfkr
      • Equational
      • Cryptography
      • Poseidon
      • Where-do-i-place-my-book
      • Axe
      • Bigmems
      • Builtins
      • Execloader
      • Aleo
      • Solidity
      • Paco
      • Concurrent-programs
      • Bls12-377-curves
    • Debugging
    • Std
    • Proof-automation
    • Macro-libraries
    • ACL2
    • Interfacing-tools
    • Hardware-verification
    • Software-verification
    • Math
    • Testing-utilities
  • Transformation-tools

Copy-fn

A C-to-C transformation to copy a function.

This transformation introduces a new function which is the duplicate of another.

For instance, consider the following C code:

int fibonacci(int x) {
  if (x <= 1) {
    return x;
  }
  return fibonacci(x - 1) + fibonacci(x - 2);
}

Copying fibonacci and creating a new function fib yields the following:

int fibonacci(int x) {
  if (x <= 1) {
    return x;
  }
  return fibonacci(x - 1) + fibonacci(x - 2);
}
int fib(int x) {
  if (x <= 1) {
    return x;
  }
  return fib(x - 1) + fib(x - 2);
}

This transformation is not likely to be useful in isolation. Most often it is an initial step before applying different transformations to the two duplicates.

Subtopics

Copy-fn-extdecl
Transform an external declaration.
Copy-fn-filepath-transunit-map
Transform a filepath.
Rename-fn-filepath-transunit-map
Copy-fn-fundef
Transform a function definition.
Rename-fn-transunit-ensemble
Transform a translation unit ensemble.
Copy-fn-transunit-ensemble
Transform a translation unit ensemble.
Copy-fn-extdecl-list
Transform a list of external declarations.
Rename-fn-ident-list
Rename-fn-fundef
Rename-fn-extdecl-list
Rename-fn-extdecl
Copy-fn-transunit
Transform a translation unit.
Rename-fn-transunit
Rename-fn-ident
Rename-fn-const
Rename-fn-funcall-fun
Rename a function within a funcall function expression.