Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance C/C++ preprocessor output #128

Open
jeremy-rifkin opened this issue Mar 2, 2022 · 2 comments
Open

Enhance C/C++ preprocessor output #128

jeremy-rifkin opened this issue Mar 2, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@jeremy-rifkin
Copy link

It'd be great to take advantage of CE's preprocessor tool when -E is used during C/C++ compilation. The preprocessor tool automatically filters out headers, junk line directives which clutter even the most simple of preprocessor results, and can also automatically format the output. Demo: https://godbolt.org/z/bxoj4fzq7.

The API for this is undocumented but a simple request for the preprocessor tool looks like:

{
  source: '...',
  options: [  ],
  backendOptions: {
    producePp: { 'filter-headers': true, 'clang-format': true },
    produceGccDump: {},
    produceCfg: false,
    produceDevice: false
  },
  filters: {
    binary: false,
    execute: false,
    demangle: true,
    intel: true,
    commentOnly: true,
    directives: true,
    labels: true,
    optOutput: false,
    libraryCode: true,
    trim: false
  },
  bypassCache: false,
  tools: [],
  executionParameters: { args: [], stdin: undefined },
  libraries: []
}

Maybe this could be done for both ;compile and ;asm.

@Headline Headline added the bug Something isn't working label Mar 3, 2022
@Headline
Copy link
Owner

Headline commented Apr 18, 2022

@jeremy-rifkin
I went ahead and started an implementation that allows for the filter-headers background option, but the following resulted in the same verbose output. Is something malformed with this request?

{
  "source": "...",
  "compiler": "g112",
  "options": {
    "userArguments": "-E",
    "compilerOptions": {
      "skipAsm": false,
      "executorRequest": false
    },
    "executeParameters": {
      "args": [],
      "stdin": ""
    },
    "filters": {
      "binary": false,
      "commentOnly": true,
      "demangle": true,
      "directives": true,
      "execute": false,
      "intel": true,
      "labels": true,
      "trim": false
    },
    "backendOptions": {
      "producePp": {
        "filter-headers": true
      }
    }
  }
}

@jeremy-rifkin
Copy link
Author

jeremy-rifkin commented Apr 20, 2022

My bad, it goes in compilerOptions. This should work

{
  "source": "...",
  "compiler": "g112",
  "options": {
    "userArguments": "-E",
    "compilerOptions": {
      "skipAsm": false,
      "executorRequest": false,
+     "producePp": {
+       "filter-headers": true
+     }
    },
    "executeParameters": {
      "args": [],
      "stdin": ""
    },
    "filters": {
      "binary": false,
      "commentOnly": true,
      "demangle": true,
      "directives": true,
      "execute": false,
      "intel": true,
      "labels": true,
      "trim": false
    },
-   "backendOptions": {
-     "producePp": {
-       "filter-headers": true
-     }
-   }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants