Commit Graph

7633 Commits

Author SHA1 Message Date
Fariborz Jahanian 64cda8b5f3 objective-C++ IRGen: property reference as an
lvalue when performing a derived-to-base conversion.
Fixes radar 7501812. Added an executable test to
llvm-test suite.

llvm-svn: 106247
2010-06-17 23:00:29 +00:00
Fariborz Jahanian 6fdb139cdd Do not treat @selector as lvalue (unlike g++).
Patch by Nico Weber (pr7390).

llvm-svn: 106242
2010-06-17 21:45:48 +00:00
Fariborz Jahanian 9240f3dac7 Objective-c++ IRGen. Support for @selector expression as
an lvalue. Fixes PR7390.

llvm-svn: 106235
2010-06-17 19:56:20 +00:00
Tom Care b49ec6907b Bug 7377: Fixed several bad printf format string bugs.
- Added warning for undefined behavior when using field specifier
- Added warning for undefined behavior when using length modifier
- Fixed warnings for invalid flags
- Added warning for ignored flags
- Added fixits for the above warnings
- Fixed accuracy of detecting several undefined behavior conditions
- Receive normal warnings in addition to security warnings when using %n
- Fix bug where '+' flag would remain on unsigned conversion suggestions

Summary of changes:
- Added expanded tests
- Added/expanded warnings
- Added position info to OptionalAmounts for fixits
- Extracted optional flags to a wrapper class with position info for fixits
- Added several methods to validate a FormatSpecifier by component, each checking for undefined behavior
- Fixed conversion specifier checking to conform to C99 standard
- Added hooks to detect the invalid states in CheckPrintfHandler::HandleFormatSpecifier

Note: warnings involving the ' ' (space) flag are temporarily disabled until whitespace highlighting no longer triggers assertions. I will make a post about this on cfe-dev shortly.

M    test/Sema/format-strings.c
M    include/clang/Basic/DiagnosticSemaKinds.td
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp
M    lib/Sema/SemaChecking.cpp

llvm-svn: 106233
2010-06-17 19:00:27 +00:00
Douglas Gregor ffa20398a6 When pushing a copy of the TypeLoc information for a dependent
template specialization type, copy the location information but use
the new type. Fixes PR7385.

llvm-svn: 106224
2010-06-17 16:03:49 +00:00
Charles Davis 8c02c13e19 Mangle operator names in the Microsoft C++ Mangler.
llvm-svn: 106211
2010-06-17 06:47:31 +00:00
Ted Kremenek 5df037e808 Tweak stack address checker to report multiple cases where globals may reference stack memory.
Also refactor the diagnostics so that we print out the kind of stack memory returned.

llvm-svn: 106210
2010-06-17 04:21:37 +00:00
Ted Kremenek 98008a47a0 Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.
llvm-svn: 106196
2010-06-17 01:12:20 +00:00
Ted Kremenek 17504bea33 Rework StackAddrLeakChecker to find stores of stack memory addresses to global variables
by inspecting the Store bindings instead of iterating over all the global variables
in a translation unit.  By looking at the store directly, we avoid cases where we cannot
directly load from the global variable, such as an array (which can result in an assertion failure)
and it also catches cases where we store stack addresses to non-scalar globals.
Also, but not iterating over all the globals in the translation unit, we maintain cache
locality, and the complexity of the checker becomes restricted to the complexity of the
analyzed function, and doesn't scale with the size of the translation unit.

This fixes PR 7383.

llvm-svn: 106184
2010-06-17 00:24:44 +00:00
Douglas Gregor 428119e39a When parsing cached C++ method declarations/definitions, save the
"previous token" location at the end of the class definition. This
eliminates a badly-placed error + Fix-It when the ';' following a
class definition is missing. Fixes <rdar://problem/8066414>.

llvm-svn: 106175
2010-06-16 23:45:56 +00:00
Douglas Gregor 13d0568ecc Make the "extra ';' inside a struct or union" diagnostic more
precise. Fixes PR7336.

llvm-svn: 106170
2010-06-16 23:08:59 +00:00
Douglas Gregor bb1196534c When we see a 'template' disambiguator that marks the next identifier
(or operator-function-id) as a template, but the context is actually
non-dependent or the current instantiation, allow us to use knowledge
of what kind of template it is, e.g., type template vs. function
template, for further syntactic disambiguation. This allows us to
parse properly in the presence of stray "template" keywords, which is
necessary in C++0x and it's good recovery in C++98/03.

llvm-svn: 106167
2010-06-16 23:00:59 +00:00
Douglas Gregor f7d7771812 Fix the recently-added warning about 'typename' and 'template'
disambiguation keywords outside of templates in C++98/03. Previously,
the warning would fire when the associated nested-name-specifier was
not dependent, but that was a misreading of the C++98/03 standard:
now, we complain only when we're outside of any template.

llvm-svn: 106161
2010-06-16 22:31:08 +00:00
Ted Kremenek 64c235e4c6 Extend format string type-checking to include '%p'. Fixes remaining cases PR 4468.
llvm-svn: 106151
2010-06-16 21:23:04 +00:00
Douglas Gregor 7dbfb46163 Canonicalize template template parameters when canonicalizing a
template name that refers to such a parameter. It's amazing that this
problem didn't surface earlier. Fixes PR7387.

llvm-svn: 106147
2010-06-16 21:09:37 +00:00
Daniel Dunbar aa2d0ceaa9 tests: Update Frontend config to actually run ir-support tests.
llvm-svn: 106144
2010-06-16 20:04:36 +00:00
Rafael Espindola 23a8a06554 Change the test for which ABI/CC to use on ARM to be base on the environment
(the last argument of the triple).

llvm-svn: 106131
2010-06-16 19:01:17 +00:00
Fariborz Jahanian 1d44608cc1 Make sure result type of objc++ message expression is
complete before attempting to bind it to a temporary.
Fixes PR7386.

llvm-svn: 106130
2010-06-16 18:56:04 +00:00
Rafael Espindola ad64acde72 A a new test for my previous patch.
llvm-svn: 106120
2010-06-16 18:02:31 +00:00
Rafael Espindola b35e7b8659 Fix tests that I missed from my previous commit.
llvm-svn: 106118
2010-06-16 17:49:52 +00:00
Douglas Gregor 94584683fa Don't poke at an undefined class type of a field. Fixes PR7355.
llvm-svn: 106111
2010-06-16 16:54:04 +00:00
Douglas Gregor 010815a20b Downgrade the error when using a typedef in the nested-name-specifier
of an explicit instantiation to an ExtWarn, since nobody else seems to
diagnose this problem.

llvm-svn: 106109
2010-06-16 16:26:47 +00:00
Douglas Gregor 1c69bf00ae If a non-dependent base class initializer fails to match any direct or
virtual base class, but the class still has dependent base classes,
then don't diagnose the failed match as an error: the right base class
might magically appear. Fixes PR7259.

llvm-svn: 106103
2010-06-16 16:03:14 +00:00
John McCall 38e5f433b2 Fix the build. Using declarations should not be considering when looking
for overridden virtual methods.

llvm-svn: 106096
2010-06-16 09:33:39 +00:00
John McCall e9cccd86da Fix a point of semantics with using declaration hiding: method templates
introduced by using decls are hidden even if their template parameter lists
or return types differ from the "overriding" declaration.

Propagate using shadow declarations around more effectively when looking up
template-ids.  Reperform lookup for template-ids in member expressions so that
access control is properly set up.

Fix some number of latent bugs involving template-ids with totally invalid
base types.  You can only actually get these with a scope specifier, since
otherwise the template-id won't parse as a template-id.

Fixes PR7384.

llvm-svn: 106093
2010-06-16 08:42:20 +00:00
Zhongxing Xu 0fa7cddbab Add StreamChecker. This checker models and checks stream manipulation functions.
This is the start.

llvm-svn: 106082
2010-06-16 05:38:05 +00:00
Charles Davis 89338af1ff Start mangling function types in the Microsoft C++ Mangler.
llvm-svn: 106081
2010-06-16 05:33:16 +00:00
Fariborz Jahanian 56d3b8c578 Moved objective-c++ code gen. tests to their own directory and
added a new test case (related to radar 8070772).

llvm-svn: 106067
2010-06-15 23:49:10 +00:00
Fariborz Jahanian 021510e96f Patch adds support for copying of those
objective-c++ class objects which have GC'able objc object
pointers and need to use ObjC's objc_memmove_collectable
API (radar 8070772). 

llvm-svn: 106061
2010-06-15 22:44:06 +00:00
Douglas Gregor f267edd8ac Update equality and relationship comparisons of pointers to reflect
C++ semantics, eliminating an extension diagnostic that doesn't match
C++ semantics (ordered comparison with NULL) and tightening some
extwarns to errors in C++ to match GCC and maintain conformance in
SFINAE contexts. Fixes <rdar://problem/7941392>.

llvm-svn: 106050
2010-06-15 21:38:40 +00:00
Douglas Gregor 9858ed5b69 Teach code completion not to ignore data members when performing code
completion for expressions.

llvm-svn: 106037
2010-06-15 20:26:51 +00:00
Chris Lattner 58efac6120 add a testcase, from Michael Spencer
llvm-svn: 106026
2010-06-15 18:56:20 +00:00
Chris Lattner c548be9ab3 Remove a dead argument to ProcessUCNEscape.
Fix string concatenation to treat escapes in concatenated strings that
are wide because of other string chunks to process the escapes as wide
themselves.  Before we would warn about and miscompile the attached testcase.

This fixes rdar://8040728 - miscompile + warning: hex escape sequence out of range

llvm-svn: 106012
2010-06-15 18:06:43 +00:00
Douglas Gregor 0832963acd Implement -fvisibility-inlines-hidden. <rdar://problem/7819834>
llvm-svn: 106003
2010-06-15 17:05:35 +00:00
Benjamin Kramer ad36eb2911 Fix typo.
llvm-svn: 105993
2010-06-15 08:21:35 +00:00
Ted Kremenek 4c721bf892 Change AnalysisConsumer to analyze functions created by instantiantiating a macro. Fixes PR 7361.
llvm-svn: 105984
2010-06-15 00:55:40 +00:00
Douglas Gregor 4f6e8deec4 Make sure to set the visible on a vtable; VTTs and typeinfo already
handle visibility properly. Fixes <rdar://problem/8091955>. 

llvm-svn: 105977
2010-06-14 23:41:45 +00:00
Douglas Gregor 1726d1517e Add name mangling for address spaces. We use the vendor-extension
mangling for types, where the <source-name> is ASxxx (xxx is the
address-space number).

llvm-svn: 105975
2010-06-14 23:15:08 +00:00
Douglas Gregor c9d2682df3 Warn when a 'typename' or a 'template' keyword refers to a
non-dependent type or template name, respectively, in C++98/03. Fixes
PR7111 and <rdar://problem/8002682>.

llvm-svn: 105968
2010-06-14 22:07:54 +00:00
Daniel Dunbar 5a9d1835be Driver: Fix PR4062 by dissecting one particular -Wp, form.
llvm-svn: 105966
2010-06-14 21:37:09 +00:00
Daniel Dunbar fb3d747fc6 Driver: Dissect -Wl, and -Xlinker arguments to remove --no-demangle, which was a
collect2 option that is passed by some projects (notably WebKit).

llvm-svn: 105964
2010-06-14 21:23:12 +00:00
Benjamin Kramer c0b8f3bc53 Enable basic testing of __builtin_fpclassify.
llvm-svn: 105937
2010-06-14 10:41:45 +00:00
Charles Davis 2d7b10cc97 Microsoft C++ Mangler:
- Mangle qualifiers.
- Start mangling variables' types into the name. A variable declared with a
  builtin type should now mangle properly.

llvm-svn: 105931
2010-06-14 05:29:01 +00:00
Chris Lattner f3d3b36870 Allow an asm label specifier on C++ methods, like GCC does.
Patch by David Majnemer!

llvm-svn: 105909
2010-06-13 05:34:18 +00:00
Chris Lattner bc6bcabc61 fix PR7360: -P mode turns off line markers, but not blank space.
Apparently some programs which abuse the preprocessor depend 
on this.

llvm-svn: 105889
2010-06-12 16:20:56 +00:00
Charles Davis 7dacc95299 Microsoft C++ Mangler:
- Don't mangle static variables at global scope.
- Add support for mangling builtin types. This will be used later.

llvm-svn: 105881
2010-06-12 08:11:16 +00:00
John McCall 45d30c3e36 When deciding whether an expression has the boolean nature, don't look through
explicit casts.  Fixes PR7359.

llvm-svn: 105871
2010-06-12 01:56:02 +00:00
Argyrios Kyrtzidis 9116717189 Fix PCH issue. Attributes of a declaration were truncated to just one when the decl was read from a PCH file.
llvm-svn: 105852
2010-06-11 23:09:25 +00:00
Daniel Dunbar d839e77b12 Preprocessor: Ignore unknown pragmas in -E -dM and -Eonly modes.
llvm-svn: 105830
2010-06-11 20:10:12 +00:00
John McCall 875679eea0 Fix the constant evaluator for AltiVec-style vector literals so that the
vector is filled with the given constant;  we were just initializing the
first element.

llvm-svn: 105824
2010-06-11 17:54:15 +00:00