In the source code, I have a negative int literal. When I parse the source code through libclang, the integer_leteral functions clang_Cursor_Evaluate and clang_EvalResult_getAsInt return a positive value for this.
For example, I had int a = -555 in the source code. If you get this integer_value and call the clang_Cursor_Evaluate and clang_EvalResult_getAsInt functions for it, the latter will simply return 555. Why is this happening?
There are no negative integer literals in C and C++. When you have something like
-555that's an integer literal555and a unary minus operator. A decimal integer has a signed integral type that won't be promoted, so that works out to the expected type and value.