Re: [cfe-users] How to change alignment of long long

2016-10-22 Thread Philipp Klaus Krause via cfe-users
Found another one that encountered this problem:

http://lists.llvm.org/pipermail/cfe-dev/2013-October/032554.html

Again no solution there.

Is anyone sucessfully using clang (preferably 3.8) with an alignment for
long long or double that is not 64 bits?

Philipp

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Use of undeclared identifier error

2016-10-22 Thread Rohan Smith via cfe-users

Hi,

I've got a program using libclang to compile C/C++ scripts at run-time. 
When trying to use it with libstdc++, specifically , although I 
get similar errors when using other standard headers, I get errors of 
the form "use of undeclared identifier '__builtin_clz'; did you mean 
'__builtin_clz'?" or "unknown type name '__builtin_va_list'; did you 
mean '__builtin_va_list'?"


I've checked the list of identifiers to see that __builtin_clz (and 
others that it's complaining about) are in there, and __builtin_va_list 
is defined in the ASTContext.


The full code for how I've set up and am calling the compilation are at 
http://pastebin.com/SASu4xMi and the output from clang::ParseAST when 
including  is at http://pastebin.com/UphYaNj8 . Despite the 
outside saying that those builtins exist, using the program at 
http://pastebin.com/UphYaNj8 says that the builtins don't exist at 
compilation time.


Cheers,

Rohan Smith

___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


Re: [cfe-users] How to change alignment of long long

2016-10-22 Thread Philipp Klaus Krause via cfe-users
On 22.10.2016 09:35, Philipp Klaus Krause via cfe-users wrote:
> Found another one that encountered this problem:
> 
> http://lists.llvm.org/pipermail/cfe-dev/2013-October/032554.html
> 
> Again no solution there.
> 
> Is anyone sucessfully using clang (preferably 3.8) with an alignment for
> long long or double that is not 64 bits?
> 
> Philipp

To all the other encountering this issue: I was able to track down the
issue.

In general, alignment handling in clang is a mess.

Yes, there are some values in the Target for alignment, but they dont't
always do what one might think. They seem to be fine for char, int, long
and float. For short, there is none, as short alignment is hardcoded to
16 bits. For long long and double there are alignment values, but they
are not used. Instead the width is used as alignment: In
ASTContext::getPreferredTypeAlign, unless the target is xcore, for
double, long long and unsigned long long, the alignment of the type is
replaced by the width.
So, to make alignment for long long and double work, you need add a
special case for your target in ASTContext::getPreferredTypeAlign like
there already is for xcore. And to make alignment work for short, you
need to make getShortAlign() virtual in TargetInfo and override it in
your Target.

Philipp

P.S.: I am using clang 3.8, the above might or might not apply to other
versions.




signature.asc
Description: OpenPGP digital signature
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users