[cfe-users] Header errors using Clang

2016-07-29 Thread Ray Mitchell via cfe-users
I just installed the 64-bit versions of Clang 3.8.1 and MinGW 5.1.0 on my 
64-bit Windows 10 system.  Everything seemed to install fine but I'm getting 
lots of errors, not warnings, on the contents of the standard header files. I 
first set my INCLUDE path to where my Microsoft VS 2015 headers are located, 
then changed it to where my mingw64 headers are located but there were content 
errors in both cases. In the mingw64 case the following is a typical error:

C:\mingw64\x86_64-w64-mingw32\include\stdio.h:179:86: error: expected ';' after 
top level declarator int __cdecl __mingw_sprintf (char * __restrict__ , const 
char * __restrict__ , ...) __MINGW_NOTHROW;

whereas in the VS2015 case the following is typical:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\limits:611:33: 
error: use of undeclared identifier
'char16_t'
template<> class numeric_limits

I also tried the -std=c++98 through -std=c++14 switches to no avail. The 
respective headers work fine with the gcc and cl compilers. Is there some other 
set of headers I should be using that is specifically tailored to Clang itself 
or am I simply doing something wrong?

The file I am compiling is named test.cpp and it merely contains:
#include 
int main()
{
  std::cout << "Hello world!\n";
  return 0;
}

The command line I am using is: clang++ -c test.cpp

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


[cfe-users] Missing header files in AST display

2017-08-02 Thread Ray Mitchell via cfe-users
Title: Missing header files in AST display


I can currently successfully compile and link C and C++ code on my Windows 10 system but I would also like to be able to separately generate the AST for each file.  The command line below does display much of the AST but it contains errors regarding missing header files that my files have included.  For normal compiling I use the -I dir option in the standard way to specify header file paths but that does not seem to work with the command line below.  How should this be done?
   clang -cc1 -ast-dump test.c



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


Re: [cfe-users] cfe-users Digest, Vol 55, Issue 3 - Re: Missing header files in AST display

2017-08-03 Thread Ray Mitchell via cfe-users
Title: Re: cfe-users Digest, Vol 55, Issue 3 - Re: Missing header files in AST display


Thursday, August 3, 2017, 12:00:01 PM, you wrote:

> Send cfe-users mailing list submissions to
>         cfe-users@lists.llvm.org

> To subscribe or unsubscribe via the World Wide Web, visit
>         http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
> or, via email, send a message with subject or body 'help' to
>         cfe-users-requ...@lists.llvm.org

> You can reach the person managing the list at
>         cfe-users-ow...@lists.llvm.org

> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of cfe-users digest..."


> Today's Topics:

>    1. Re: Missing header files in AST display
>       (Raphael Isemann via cfe-users)

Raphael,

I was referring to the default include paths and your sample
command line did the trick and it all works well now.  Thanks
a lot for your help.

Ray


> --

> Message: 1
> Date: Wed, 2 Aug 2017 22:46:02 +0200
> From: Raphael Isemann via cfe-users <cfe-users@lists.llvm.org>
> To: Ray Mitchell <raymitch...@meanoldteacher.com>
> Cc: cfe-users@lists.llvm.org
> Subject: Re: [cfe-users] Missing header files in AST display
> Message-ID:
>        
> <CADrqtg7HG5kGu5BjMrBf9J60GR0FcCj=22g0zdngkalapvp...@mail.gmail.com>
> Content-Type: text/plain; charset="UTF-8"

> Do you mean the default include paths? Not sure how the Windows
> version is handling this, but if a normal clang compilation works for
> you, then this should make the ast-dump working with all include
> default paths:

> clang -Xclang -ast-dump -fsyntax-only -I/your/usual/extra/paths test.c

> Note that there is no -cc1 but instead we only add the -ast-dump to
> the -cc1 invocation via -Xclang. This way you also get your default
> include paths from the driver.

> Otherwise you should write an example invocation that fails to find a
> certain header in a certain path, because with the current information
> it's hard to say what exactly is going wrong.

> - Raphael

> 2017-08-02 20:07 GMT+02:00 Ray Mitchell via cfe-users
> <cfe-users@lists.llvm.org>:
>> I can currently successfully compile and link C and C++ code on my Windows
>> 10 system but I would also like to be able to separately generate the AST
>> for each file.  The command line below does display much of the AST but it
>> contains errors regarding missing header files that my files have included.
>> For normal compiling I use the -I dir option in the standard way to specify
>> header file paths but that does not seem to work with the command line
>> below.  How should this be done?
>>   clang -cc1 -ast-dump test.c

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



> --

> Subject: Digest Footer

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


> --

> End of cfe-users Digest, Vol 55, Issue 3
> 




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


[cfe-users] Suppress header file information in AST; also, function prototypes vs definitions

2017-11-04 Thread Ray Mitchell via cfe-users
Title: Suppress header file information in AST; also, function prototypes vs definitions


I'm using clang 3.7 and am currently generating an AST for my test.c file with the following Windows 10 command line:
   clang -Xclang -ast-dump -fsyntax-only test.c

1. Is there any option that will suppress AST information from being generated for files that have been included in test.c via #include?  I only want it for the code that is actually in the file.

2. Due to the fairly simplistic tasks I am using the AST for at the moment I am merely parsing it myself rather than using libtooling or something more exotic.  One thing I'm finding more complex than I'd like is that function prototypes and the declaration part of function definitions seem to be exactly the same in themsleves and I am forced to parse additional lines to differentiate them.  Is there something I'm missing that would make differentiating them more straightforward?



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


[cfe-users] clang-format -style=file fails

2018-02-17 Thread Ray Mitchell via cfe-users
I'm trying to configure a custom style options file for clang-format v6.0.0 
running on Windows 10 Pro 64-bit.  I started out by generating a configuration 
file based upon the llvm style using the following command line, which worked 
fine:
clang-format -style=llvm -dump-config > .clang-format

The documentation for clang-format states the following:
"When the desired code formatting style is different from the available 
options, the style can be customized using the -style="{key: value, ...}" 
option or by putting your style configuration in the .clang-format or 
_clang-format file in your project’s directory and using clang-format 
-style=file." 

So just as a test I used the unchanged .clang-format file I generated above and 
used the following command line:
clang-format -style=.clang-format Test.c
The result was a message that said "Invalid value for -style".  I then changed 
the name of .clang-format to _clang-format and tried it again but the result 
was the same.  So, my question is, "How do I specify a specific style options 
file?"

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


[cfe-users] Format of AST entries?

2018-02-20 Thread Ray Mitchell via cfe-users
I am attempting to do some basic parsing of the AST using C#.  So far I've had 
success extracting a few things simply by writing some test C++ code, 
generating an AST for it, making some changes, regenerating an AST, and 
observing what changes in the AST entries.  However, this empirical approach is 
pretty brutal and requires a lot of questionable assumptions.  Is there any 
documentation that explicitly explains the possible permutations and field 
meanings of each AST entry type?  If so I'd greatly appreciate a link to it.  
I've done pretty well figuring out the FunctionDecl item and a few others but a 
document describing them would really be helpful.  For example, in the 
following I know that 'ABCDE' represents the name of the function and 'float 
(int, char)' represents its data type, but there are two copies of 'float (int, 
char)' and I'd like to know why and if they both represent the same thing:

|| `-DeclRefExpr 0x862c118  'float (int, char)' lvalue Function 
0x85deae0 'ABCDE' 'float (int, char)'

I have similar questions about most of the entry types.
Thanks,
Ray___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] clang-format "ContinuationIndentWidth: 3" format style not working?

2018-03-02 Thread Ray Mitchell via cfe-users
Hello,

I am currently using the following format style options with clang-format 
v6.0.0:

---
Language:Cpp
TabWidth: 3
IndentWidth: 3
ContinuationIndentWidth: 3
IndentCaseLabels: false
BreakBeforeBraces: Custom
BraceWrapping:
  AfterClass: true
  AfterControlStatement: true
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  AfterExternBlock: true
  BeforeCatch: true
  BeforeElse: true
...


Here a snippet of my original code, which uses 3-space indents and doesn't look 
to me like it should be changed at all by clang-format:

   for (bin = hashTable->firstBin; bin < end; ++bin)
   {
  printf("%d entries for bin %d:\n",
 (int)bin->nodes, (int)(bin - hashTable->firstBin)); 

  PrintTree(bin->firstNode);
   }

However, clang-format changes the continuation line of printf as shown below.  
Note that it is now indented by 7 spaces from the printf instead of the 3 
spaces I would expect.  In addition, obviously 7 isn't even an integral 
multiple of 3.  Is there something additional I should specify to correct this?

   for (bin = hashTable->firstBin; bin < end; ++bin)
   {
  printf("%d entries for bin %d:\n",
 (int)bin->nodes, (int)(bin - hashTable->firstBin)); 

  PrintTree(bin->firstNode);
   }
   
Thanks,
Ray
___
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users


[cfe-users] Some basic AST file generation questions

2021-03-25 Thread Ray Mitchell via cfe-users
Win10-64, clang v11.0.0, VS2019

When I enter "clang.exe -help" from the command line I get a long list of clang 
options, and one of them is "-Xclang ".  Thanks to previous help from a 
member of the cfe-users digest, I am able to do "clang.exe -Xclang -ast-dump 
-fsyntax-only SourceFile.c" to get the AST file for my source file.  I have 
some basic questions about all this:

1. I may have asked this before, but I've forgotten :-(  The -ast-dump and 
-fsyntax-only options above are not listed when I enter "clang.exe -help".  Is 
there a command line option that will list these and all other options that are 
missing from the basic -help list?  If so, what is it?  If not, specifically 
where can I find these additional options listed and described?

2. All of the following code I describe compiles, links, and runs correctly:  I 
have an include guard protected header file named MyClass.h that includes a 
couple standard library headers followed by the declaration of a const variable 
followed by the definition of C++ class named MyClass followed by the 
definition of an inline function.  When I do "clang.exe -Xclang -ast-dump 
-fsyntax-only MyClass.h" the resulting AST file contains the typical AST 
information from the two included header files, but only contains the two 
following lines for my code:
|-VarDecl 0xb1ba010  col:7 invalid MyClass 'int'
`-VarDecl 0xb1ba060  col:13 invalid MyClass 'void'
When I look at the AST files produced for any of my implementation files that 
contain #include "MyClass.h", the complete AST information for MyClass.h is 
there.  Why is most of that AST information missing from the AST file produced 
directly from MyClass.h and how can I cause it to be there?

Thank you :-)
Ray___
cfe-users mailing list
cfe-users@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users