Douglas Gregor [Tue, 10 Nov 2009 19:49:08 +0000 (19:49 +0000)]
Improve parsing of template arguments to lay the foundation for
handling template template parameters properly. This refactoring:
- Parses template template arguments as id-expressions, representing
the result of the parse as a template name (Action::TemplateTy)
rather than as an expression (lame!).
- Represents all parsed template arguments via a new parser-specific
type, ParsedTemplateArgument, which stores the kind of template
argument (type, non-type, template) along with all of the source
information about the template argument. This replaces an ad hoc
set of 3 vectors (one for a void*, which was either a type or an
expression; one for a bit telling whether the first was a type or
an expression; and one for a single source location pointing at
the template argument).
- Moves TemplateIdAnnotation into the new Parse/Template.h. It never
belonged in the Basic library anyway.
Ted Kremenek [Tue, 10 Nov 2009 19:18:52 +0000 (19:18 +0000)]
CIndex: Only display diagnostics to llvm::errs() when the client has set the 'displayDiagnostics' option to 1 in clang_createIndex(). This fixes <rdar://problem/7370691>.
Daniel Dunbar [Tue, 10 Nov 2009 18:47:41 +0000 (18:47 +0000)]
Driver: Run 'clang' in C++ mode based on the name it was invoked by. We match
anything that ends with ++ or ++-FOO (e.g., c++, clang++, clang++-1.1) as being
a "C++ compiler".
This allows easy testing of the C++ compiler by 'ln -s clang clang++', or by 'cp
clang clang++'.
Daniel Dunbar [Tue, 10 Nov 2009 17:50:53 +0000 (17:50 +0000)]
Localize -disable-llvm-optzns handling to BackendConsumer::CreatePasses.
- This is conceptually better since the only thing we want this option to do is
preserve the internal module as constructed by IRgen, before running any
passes.
- This also fixes bugs in -disable-llvm-optzns handling with regards to debug
info.
John McCall [Tue, 10 Nov 2009 09:25:37 +0000 (09:25 +0000)]
Fix a similar problem with qualified lookup through using directives,
although in this case we probably just run a risk of duplicating work;
I can't think of how this could cause a bug.
John McCall [Tue, 10 Nov 2009 09:20:04 +0000 (09:20 +0000)]
Make a somewhat more convincing test case for unqualified lookup through
using directives, and fix a bug thereby exposed: since we're playing
tricks with pointers, we need to make certain we're always using the same
pointers for things.
Also tweak an existing error message.
Zhongxing Xu [Tue, 10 Nov 2009 07:52:53 +0000 (07:52 +0000)]
SizeofPointerChecker: Many false positives have the form 'sizeof *p'.
This is reasonable because people know what they are doing when they
intentionally dereference the pointer.
So now we only emit warning when a pointer variable is use literally.
Anders Carlsson [Tue, 10 Nov 2009 04:46:30 +0000 (04:46 +0000)]
When trying to assign a regular string literal to an Objective-C 'id' type or a pointer to an NSString, emit a code insertion hint that turns it into an Objective-C string. For example:
@class NSString;
@interface Test
+ (void)test:(NSString *)string;
@end
Anders Carlsson [Tue, 10 Nov 2009 03:24:44 +0000 (03:24 +0000)]
If a function with a default argument is redefined and the new function also has a defualt argument then add a fixit hint that removes the default argument. Fixes PR5444.
Daniel Dunbar [Mon, 9 Nov 2009 22:45:57 +0000 (22:45 +0000)]
Change clang-cc to expect that all inputs have the same language (so we can only construct a single LangInfo). This matches how it is used in practice (since the compiler only it invokes it for one file at a time).
Changed error for nested type qualifier mismatch to
warning, to match gcc. It used to be warning, so
better keep it a warning (it broke a certain project).
Douglas Gregor [Mon, 9 Nov 2009 22:08:55 +0000 (22:08 +0000)]
Make sure that Type::getAs<ArrayType>() (or Type::getAs<subclass of
ArrayType>()) does not instantiate. Update all callers that used this
unsafe feature to use the appropriate ASTContext::getAs*ArrayType method.
Douglas Gregor [Mon, 9 Nov 2009 21:35:27 +0000 (21:35 +0000)]
Make sure that we look into nested, transparent declaration contexts
when looking for a name within a given DeclContext. Now enumerators
will show up in code-completion results.
Eli Friedman [Mon, 9 Nov 2009 19:20:36 +0000 (19:20 +0000)]
Add additional note to mark the cause of synthesized constructors. Mark
declaration invalid if the constructor can't be properly built. Addresses
remaining review comments from Fariborz for r86500.
Douglas Gregor [Mon, 9 Nov 2009 19:17:50 +0000 (19:17 +0000)]
Improve instantiation of default template arguments for nested
templates. The instantiation of these default arguments must be (and
now, is) delayed until the template argument is actually used, at
which point we substitute all levels of template arguments
concurrently.
Eli Friedman [Mon, 9 Nov 2009 18:38:53 +0000 (18:38 +0000)]
Add support for cdecl attribute. (As far as I know, it doesn't affect CodeGen
unless we start implementing command-line switches which override the default
calling convention, so the effect is mostly to silence unknown attribute
warnings.)
Steve Naroff [Mon, 9 Nov 2009 17:45:52 +0000 (17:45 +0000)]
Introduce CXString type and associated functions clang_getCString() and clang_disposeString().
This abstraction will help us manage string memory for complex names that cross the C++/C boundary (e.g. ObjC methods, selectors). This patch also uses it in clang_getTranslationUnitSpelling (which I'm not sure is necessary). Will investigate later...since the extra malloc() can't hurt (for now).
Douglas Gregor [Mon, 9 Nov 2009 16:04:45 +0000 (16:04 +0000)]
Minor cleanup for CIndex-based code-completion:
- Provide an actual test for code-completion via CIndex.
- Actually print optional strings in c-index-test
- Export clang_getCompletionChunkCompletionString from CIndex
Zhongxing Xu [Mon, 9 Nov 2009 05:34:10 +0000 (05:34 +0000)]
Add checker for CWE-469: Use of Pointer Subtraction to Determine Size. This
checker does not build sink nodes. Because svaluator computes an unknown value
for the subtraction now.
Eli Friedman [Mon, 9 Nov 2009 01:05:47 +0000 (01:05 +0000)]
Unify the codepaths used to verify base and member initializers for explicitly
and implicitly defined constructors. This has a number of benefits:
1. Less code.
2. Explicit and implicit constructors get the same diagnostics.
3. The AST explicitly contains constructor calls from implicit default
constructors. This allows handing some cases that previously weren't handled
correctly in IRGen without any additional code. Specifically, implicit default
constructors containing calls to constructors with default arguments are now
handled correctly.
Sebastian Redl [Sun, 8 Nov 2009 13:56:19 +0000 (13:56 +0000)]
Special-case default argument expression in instantiation. This should fix PR4301. Doug, please double-check my assumptions. Read the PR for more details.