Clang 2.7 and C++ support

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang 2.7 and C++ support

Simone Pellegrini
Hi all,
I was wondering if C++ support will be enabled by default in this
release or we would have to wait the next release (2.8).

and if not, is there any way to enable it?

cheers, Simone
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang 2.7 and C++ support

Zhongxing Xu
Hi Simone,

You can use clang++ just like g++.

On Tue, Apr 20, 2010 at 3:03 PM, Simone Pellegrini <[hidden email]> wrote:
Hi all,
I was wondering if C++ support will be enabled by default in this
release or we would have to wait the next release (2.8).

and if not, is there any way to enable it?

cheers, Simone
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang 2.7 and C++ support

Douglas Gregor
In reply to this post by Simone Pellegrini

On Apr 20, 2010, at 12:03 AM, Simone Pellegrini wrote:

> Hi all,
> I was wondering if C++ support will be enabled by default in this
> release or we would have to wait the next release (2.8).
>
> and if not, is there any way to enable it?

C++ support is enabled by default in 2.7.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang 2.7 and C++ support

Simone Pellegrini
On 04/20/2010 09:25 AM, Douglas Gregor wrote:
On Apr 20, 2010, at 12:03 AM, Simone Pellegrini wrote:

  
Hi all,
I was wondering if C++ support will be enabled by default in this 
release or we would have to wait the next release (2.8).

and if not, is there any way to enable it?
    
C++ support is enabled by default in 2.7. 
  
What I am doing is using clang as a library so I cannot use the clang driver directly.

I manually instantiate a CompilerInstance and feed C++ code and get the following error:

error: unknown type name 'class'

I also tried to feed the "-ccc-clang-cxx" flag as suggested in: http://clang.llvm.org/docs/UsersManual.html#cxx
but it didn't help.

The actual code I use to instantiate a compiler is the following:

CompilerInstance Clang;
Clang.setLLVMContext(new llvm::LLVMContext);
Clang.createDiagnostics(argc, argv);
           
Clang.setFileManager(&FileMgr);
Clang.createSourceManager();

Clang.InitializeSourceManager(File->getName());
 
// Add the default clang system headers
Clang.getHeaderSearchOpts().AddPath( "/software/llvm-2.7/lib/clang/1.1/include/", clang::frontend::System, true, false );
// add user headers
for (size_t i = 0; i < Flags::I_dirs.size(); ++i)
       Clang.getHeaderSearchOpts().AddPath( Flags::I_dirs[i], clang::frontend::Angled, true, false);

TargetOptions TO;
TO.Triple = llvm::Triple("x86_64", "PC", "Linux").getTriple();
Clang.setTarget( TargetInfo::CreateTargetInfo (Clang.getDiagnostics(), TO) );

// A compiler invocation object has to be created in order for the diagnostics to work
CompilerInvocation* CI = new CompilerInvocation; // CompilerInvocation will be deleted by CompilerInstance

const char* arg = "ccc-clang-cxx";
CompilerInvocation::CreateFromArgs(*CI, &arg, &arg+1, Clang.getDiagnostics());
Clang.setInvocation(CI);

Clang.createPreprocessor();
Clang.createASTContext();
 
...

what am I doing wrong? The code works perfectly for C programs!!

Where I can find the code

	- Doug
  


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang 2.7 and C++ support

Douglas Gregor

On Apr 20, 2010, at 1:02 AM, Simone Pellegrini wrote:

On 04/20/2010 09:25 AM, Douglas Gregor wrote:
On Apr 20, 2010, at 12:03 AM, Simone Pellegrini wrote:

  
Hi all,
I was wondering if C++ support will be enabled by default in this 
release or we would have to wait the next release (2.8).

and if not, is there any way to enable it?
    
C++ support is enabled by default in 2.7. 
  
What I am doing is using clang as a library so I cannot use the clang driver directly.

I manually instantiate a CompilerInstance and feed C++ code and get the following error:

error: unknown type name 'class'

I also tried to feed the "-ccc-clang-cxx" flag as suggested in: http://clang.llvm.org/docs/UsersManual.html#cxx
but it didn't help.

The actual code I use to instantiate a compiler is the following:

CompilerInstance Clang;
Clang.setLLVMContext(new llvm::LLVMContext);
Clang.createDiagnostics(argc, argv);
           
Clang.setFileManager(&FileMgr);
Clang.createSourceManager();

Clang.InitializeSourceManager(File->getName());
 
// Add the default clang system headers
Clang.getHeaderSearchOpts().AddPath( "/software/llvm-2.7/lib/clang/1.1/include/", clang::frontend::System, true, false );
// add user headers
for (size_t i = 0; i < Flags::I_dirs.size(); ++i)
       Clang.getHeaderSearchOpts().AddPath( Flags::I_dirs[i], clang::frontend::Angled, true, false);

TargetOptions TO;
TO.Triple = llvm::Triple("x86_64", "PC", "Linux").getTriple();
Clang.setTarget( TargetInfo::CreateTargetInfo (Clang.getDiagnostics(), TO) );

// A compiler invocation object has to be created in order for the diagnostics to work
CompilerInvocation* CI = new CompilerInvocation; // CompilerInvocation will be deleted by CompilerInstance

const char* arg = "ccc-clang-cxx";
CompilerInvocation::CreateFromArgs(*CI, &arg, &arg+1, Clang.getDiagnostics());
Clang.setInvocation(CI);

Clang.createPreprocessor();
Clang.createASTContext();
 
...

what am I doing wrong? The code works perfectly for C programs!!

I don't see where you're setting the LangOption bit that tells it to compile C++ code.

- Doug

_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev