Eli Friedman [Wed, 7 Sep 2011 01:41:24 +0000 (01:41 +0000)]
Switch clang over to using fence/atomicrmw/cmpxchg instead of the intrinsics (which will go away). LLVM CodeGen does almost exactly the same thing with these and the old intrinsics, so I'm reasonably confident this will not break anything.
There are still a few issues which need to be resolved with code generation for atomic load and store, so I'm not converting the places which need those for now.
I'm not entirely sure what to do about __builtin_llvm_memory_barrier: the fence instruction doesn't expose all the possibilities which can be expressed by __builtin_llvm_memory_barrier. I would appreciate hearing from anyone who is using this intrinsic.
Richard Trieu [Wed, 7 Sep 2011 00:58:53 +0000 (00:58 +0000)]
Change the self-reference visitor (which gives the warning for self-reference oninitalization warning of -Wuninitialized) to exclude member variables that can decay into pointers. This will cause it to no longer warn on this code:
In Microsoft mode, if we are inside a template class member function and we can't resolve a function call then create a type-dependent CallExpr even if the function has no type dependent arguments. The goal is to postpone name lookup to instantiation time to be able to search into type dependent base classes.
With this patch in, clang will generate only 37 errors (down from 212) when parsing a typical MFC source file.
Use ArrayRef for the fixit hint array rather than a pointer and a size.
Clean up loops over the hints to use the more idiomatic iterator form in
LLVM and Clang.
Hoist the construction of the FixItHint line into a member function with
a defined interface. This isn't as nice as the previous one, but should
get better as I push through better data types in all these functions.
Also, I'm hoping to pull some aspects of this out into a common routine
(such as tab expansion).
Again, WIP, comments welcome as I'm going through.
Douglas Gregor [Tue, 6 Sep 2011 21:41:04 +0000 (21:41 +0000)]
When extracting the callee declaration from a call expression, be sure
to look through SubstNonTypeTemplateParmExprs. Then, update the IR
generation of CallExprs to actually use CallExpr::getCalleeDecl()
rather than attempting to mimick its behavior (badly).
Eli Friedman [Tue, 6 Sep 2011 18:53:03 +0000 (18:53 +0000)]
Rearrange code so that we pass the right pointer to delete[] when an exception is thrown constructing the array elements in an array new expression. Fixes PR10870.
Richard Smith [Tue, 6 Sep 2011 18:03:41 +0000 (18:03 +0000)]
Advertise support for cxx_range_for as an extension in C++98 mode. Patch by Jean-Daniel Dupas!
Also provide a modicum of test coverage for ranged for in C++98.
Douglas Gregor [Tue, 6 Sep 2011 16:38:46 +0000 (16:38 +0000)]
Finish implementing (de-)serialization of the CXXDefinitionData bits
needed for implicit move constructors and move assignment
operators. Fixes PR10847.
Douglas Gregor [Tue, 6 Sep 2011 16:26:56 +0000 (16:26 +0000)]
When performing a derived-to-base cast on the right-hand side of the
synthesized move assignment within an implicitly-defined move
assignment operator, be sure to treat the derived-to-base cast as an
xvalue (rather than an lvalue). Otherwise, we'll end up getting the
wrong constructor.
Optimize a direct call to a trivial move assignment operator to an
aggregate copy, as we do for trivial copy assignment operators, and
update the the assertion in CodeGenFunction::EmitAggregateCopy() to
cope with this optimization.
Add the resource directory to the search path for Driver::GetFilePath,
as well as the search path printed by -print-search-dirs.
The main purpose of this change is to cause -print-file-name=include
to print the path to the include directory under Clang's resource
directory, instead of the system compiler's include directory, whose
header files Clang may not be able to parse. Some build scripts will
do something like:
$(CC) -nostdinc -I`$(CC) -print-file-name=include`
to exclude all header paths except the compiler's.
Enable -Wdangling-fields by default in Clang. I've run this warning over
a very large chunk of code and found zero false positives. I've only
found a few bugs, but that likely is because bugs of this nature
actually do manifest. We've also identified several bugs that were
caught by Valgrind, but would have been caught faster and more easily
with this warning.
If anyone has concerns, or this causes fallout on any build bots, lemme
know. I'm happy to just put it under -Wmost.
Richard Smith [Mon, 5 Sep 2011 02:13:09 +0000 (02:13 +0000)]
Implement the suggested resolution of WG21 N3307 issue 19: When determining whether a class is an aggregate in C++0x, treat all functions which are neither deleted nor defaulted as user-provided, not just special member functions. The wording of the standard only defines the term "user-provided" for special member functions, but the intent seems to be that any function can be user-provided.
Pass 0 instead of a empty TemplateArgumentListInfo when creating a CXXDependentScopeMemberExpr to handle a "this->" fixit (lookup into dependent bases of class template)
Otherwise the fixit doesn't really work for subsequent lookup.
Richard Smith [Sun, 4 Sep 2011 19:54:14 +0000 (19:54 +0000)]
PR10458: Finesse behaviour of C++0x features when in pre-0x mode. Accept for-range and auto with an ExtWarn, and produce a -Wc++0x-compat warning in C++98 mode when auto is used as a storage class.
Sebastian Redl [Sun, 4 Sep 2011 18:14:28 +0000 (18:14 +0000)]
Add test case for defaulted copy and move structure validation.
Fix bug this uncovered.
Address minor comments from Doug.
Enable cxx_implicit_moves feature.
Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.
Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.
Fix Lexer::ComputePreamble when MaxLines parameter is non-zero.
The function was only counting lines that included tokens and not empty lines,
but MaxLines (mainly initiated to the line where the code-completion point resides)
is a count of overall lines (even empty ones).
Add a simple new warning to catch blatantly dangling pointer and
reference members of classes. We've had several bugs reported because of
this, and there's no reason not to flag it right away in the compiler.
Comments especially welcome on the strategy for implementing this
warning (IE, what should trigger this?) and on the text of the warning
itself.
I'm going to extend this to cover obvious cases with temporaries and
beef up the test cases some in subsequent patches. I'll then run it over
a large codebase and make sure its not misbehaving before I add it to
-Wall or turn it on by default. I think this one might be a good
candidate for on by default.
Eli Friedman [Fri, 2 Sep 2011 17:38:59 +0000 (17:38 +0000)]
Make StmtDumper::VisitCXXFunctionalCastExpr dump the attached cast kind. Fix the cast kind for a cast from floating-point to enum type. (The difference isn't actually visible, but that's just because IRGen is overly forgiving.) Per report by Enea Zaffanella on cfe-dev.
Jordy Rose [Fri, 2 Sep 2011 05:55:19 +0000 (05:55 +0000)]
[analyzer] Move the knowledge of whether or not GC is enabled for the current analysis from CFRefCount to ExprEngine.
Remove TransferFuncs from ExprEngine and AnalysisConsumer.
Demote RetainReleaseChecker to a regular checker, and give it the name osx.cocoa.RetainCount (class name change coming shortly). Update tests accordingly.
Douglas Gregor [Fri, 2 Sep 2011 00:26:20 +0000 (00:26 +0000)]
Always construct an ASTReader with a non-NULL ASTContext and
Preprocessor, eliminating the constructor that was used by ASTUnit
(which didn't provide an ASTContext or Prepreprocessor). Ensuring that
both objects are non-NULL will simplify module loading (but none of
that is done yet).
Douglas Gregor [Fri, 2 Sep 2011 00:18:52 +0000 (00:18 +0000)]
Extend the ASTContext constructor to delay the initialization of
builtin types (When requested). This is another step toward making
ASTUnit build the ASTContext as needed when loading an AST file,
rather than doing so after the fact. No actual functionality change (yet).
Douglas Gregor [Thu, 1 Sep 2011 23:39:15 +0000 (23:39 +0000)]
Allow the preprocessor to be constructed without performing target-
and language-specific initialization. Use this to allow ASTUnit to
create a preprocessor object *before* loading the AST file. No actual
functionality change.
Richard Trieu [Thu, 1 Sep 2011 22:53:23 +0000 (22:53 +0000)]
Refactor CheckAdditionOperands(), CheckSubtractionOperands(), and CheckIncrementDecrementOperand() in SemaExpr.cpp to move reused code to separate functions.
Nick Lewycky [Thu, 1 Sep 2011 21:49:51 +0000 (21:49 +0000)]
Don't try to emit unsupported templated friend declarations. They're unsupported
and may very well be dependent-types, triggering an assertion in debug info
codegen.
Richard Trieu [Thu, 1 Sep 2011 21:44:13 +0000 (21:44 +0000)]
Extend the self-reference warning to catch when a constructor references itself upon initialization, such as using itself within its own copy constructor.
Douglas Gregor [Thu, 1 Sep 2011 20:23:19 +0000 (20:23 +0000)]
Teach ASTContext and Preprocessor to hold on to references to the same
LangOptions, rather than making distinct copies of
LangOptions. Granted, LangOptions doesn't actually get modified, but
this will eventually make it easier to construct ASTContext and
Preprocessor before we know all of the LangOptions.
Douglas Gregor [Thu, 1 Sep 2011 17:04:32 +0000 (17:04 +0000)]
Modules hide macro definitions by default, so that silly things like
include guards don't show up as macro definitions in every translation
unit that imports a module. Macro definitions can, however, be
exported with the intentionally-ugly #__export_macro__
directive. Implement this feature by not even bothering to serialize
non-exported macros to a module, because clients of that module need
not (should not) know that these macros even exist.
Enable -fdelayed-template-parsing by default on Win32.
I had to force -fno-delayed-template-parsing on some Index tests because delayed template parsing will change the output of some tests.
Fix PR10744 by adding the toolchain path to the regular program path
and doing a simple search. Before we would manually check for the linker
before the -B options were searched.
Douglas Gregor [Thu, 1 Sep 2011 02:09:07 +0000 (02:09 +0000)]
When defining the implicit move assignment operator, don't perform
semantic analysis when taking the address of an xvalue. Instead, just
build the unary operator directly, since it's safe to do so (from the
IRgen and AST perspectives) for any glvalue. Fixes PR10822.
Support importing of ObjC categories from modules.
The initial incentive was to fix a crash when PCH chaining categories
to an interface, but the fix was done in the "modules way" that I hear
is popular with the kids these days.
Each module stores the local chain of categories and we combine them
when the interface is loaded. We also warn if non-dependent modules
introduce duplicate named categories.
Chandler Carruth [Wed, 31 Aug 2011 23:59:23 +0000 (23:59 +0000)]
Create a CaretDiagnostic class to hold the logic for emitting
(unsurprisingly) caret diagnostics. This is designed to bring some
organization to the monstrous EmitCaretDiagnostic function, and allow
factoring it more easily and with less mindless parameter passing.
Currently this just lifts the existing function into a method, and
splits off the obviously invariant arguments to be class members. No
functionality is changed, and there are still lots of warts to let
existing code continue functioning as-is. Definitely WIP, more cleanups
to follow.