Comments (7)
DStep doesn't currently handle anything from the preprocessor at all.
from dstep.
So how does dstep get the 4 for the "char[4] a" if it hasn't at least remembered the value of LENGTH in some way?
from dstep.
dstep does not.
clang does run the preprocessor.
I do not think it is a good idea to handle preprocessor stuff in step...
it is best left to clang
from dstep.
So how does dstep get the 4 for the "char[4] a" if it hasn't at least remembered the value of LENGTH in some way?
It just calls the libclang function clang_getArraySize.
from dstep.
@russel it is important to remember that in C pre-processing and compiling are done in two completely separate steps. By the time source code gets to compiler (and thus to dstep which is built on top of libclang) it already looks like char[4] a
with all macros expanded.
To do what you want one needs to either plug into preprocessor and pass some state to compiler parser from it or write your own C pre-processor which replaces numeric defines with enum
instead of doing actual text substitution. Or something similar.
from dstep.
@Dicebot Ah, OK, crucial bit of information: DStep is working on the abstract syntax tree form of the code not the source itself. Sounds like a pre-pre-processor which converted #defines into either inline functions or constexpr values would be needed to solve the problem I have here.
from dstep.
@Dicebot Clang retains the full source information, that's the whole point of Clang. They tried create tools based GCC but it was difficult/impossible because it did not retain the complete source information. For example, the parser did some forms of const folding. Something like const int a = 3 + 1;
looked like const int a = 4;
in the AST.
The necessary information should be available in Clang. When I started with DStep libclang did not have an API to interact with the preprocessor. It still doesn't, but I recently noticed that they provide a translation unit flag CXTranslationUnit_DetailedPreprocessingRecord that seems to be interesting.
from dstep.
Related Issues (20)
- error: must use 'struct' tag to refer to type ... HOT 3
- typedef <typeA> <typeB>; when typeA is not in scope HOT 6
- Preprocessor macro with variadic args dropped without warning HOT 3
- LL integer literal suffix not recognized in `#define` macros HOT 1
- Pointer arithmetic and parentheses elision
- Dstep + bindbc HOT 1
- `--normalize-modules` insert underscore in the module decl but not in the filename
- typedef function prototypes don't retain arguments HOT 5
- dub run failure - ld cannot find @linker_flags.txt HOT 4
- doc error:
- Missing import HOT 2
- Unhandled type kind objCTypeParam HOT 2
- const T arr[] gets converted to imcompatible const(T) *arr instead of a warning HOT 2
- Improper output when importing core.stdc.limits HOT 1
- Rename enum members can create invalid enum names HOT 1
- API macro erased but should be extern(System) HOT 2
- /usr/include/cuda_runtime_api.h ==> d: Error: undefined identifier `cudaError_t` HOT 6
- Assertion Failure when defining a cast from int to function pointer
- Unhandled type kind objCObject when trying to bind Foundation.framework on macOS
- enh? add enum alias (as dpp do) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dstep.