Граф коммитов

22336 Коммитов

Автор SHA1 Сообщение Дата
Fariborz Jahanian b9d5c22529 More Sema Check and a test case for init_priority attr.
(radar 8076356).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106350 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 23:14:53 +00:00
Jordy Rose ba0f61cf53 Fold additive constants, and support comparsions of the form $sym+const1 <> const2
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106339 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 22:49:11 +00:00
Chris Lattner 0a76aae8c0 introduce a new CharSourceRange class, and enhance the diagnostics routines
to use them instead of SourceRange.  CharSourceRange is just a SourceRange
plus a bool that indicates whether the range has the end character resolved
or whether the end location is the start of the end token.  While most of
the compiler wants to think of ranges that have ends that are the start of
the end token, the printf diagnostic stuff wants to highlight ranges within
tokens.

This is transparent to the diagnostic stuff.  To start taking advantage of
the new capabilities, you can do something like this:
  Diag(..) << CharSourceRange::getCharRange(Begin,End)





git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106338 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 22:45:06 +00:00
Douglas Gregor 96fb42ea29 A trivial fix for a test case that's too horrible to commit. Fixes
<rdar://problem/8108088>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106328 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 22:12:56 +00:00
Fariborz Jahanian 521f12d3df Implements Sema part of init_priority(priority) attribute
(radar 8076356) - wip.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 21:44:06 +00:00
Douglas Gregor 8e19890c32 Don't complain about missing field initializers when the initializer
list is completely empty, from Lasse Kärkkäinen! Fixes PR7413.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106320 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 21:43:10 +00:00
Douglas Gregor d2c6490385 Merge the "regparm" attribute from a previous declaration of a
function to redeclarations of that function. Fixes PR7025.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106317 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 21:30:25 +00:00
Gabor Greif 4ab92891a5 John called for a less surprising cast
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106277 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 10:11:35 +00:00
Charles Davis c62458f6ae Mangle tag types (unions, structs, classes, enums) in the Microsoft C++ Mangler.
Also, test that static members with default visibility in a struct have the
right mangling.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106276 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 07:51:00 +00:00
Tom Care 4c60219950 Printf format strings: Added some more tests and fixed some minor bugs.
- Precision toStrings shouldn't print a dot when they have no value.
- Length of char length modifier is now returned correctly.
- Added several fixit tests.

Note: fixit tests are currently broken due to a bug in HighlightRange. Marking as XFAIL for now.

M    test/Sema/format-strings-fixit.c
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106275 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 03:02:16 +00:00
Zhongxing Xu 23d90f9041 Add null stream check for more APIs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106274 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 02:47:46 +00:00
Sean Hunt 568e598bf8 Rewrite comment to make my intentions slightly more clear.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106272 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 02:14:45 +00:00
Ted Kremenek f057bf78a6 Change two static variables into instance variables of ASTContext. This allows us to have multiple copies
of ASTContext at the same time.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106258 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-18 00:31:04 +00:00
Douglas Gregor c070cc602d Given Decl::isUsed() a flag indicating when to consider the "used"
attribute as part of the calculation. Sema::MarkDeclReferenced(), and
a few other places, want only to consider the "used" bit to determine,
e.g, whether to perform template instantiation. Fixes a linkage issue
with Boost.Serialization.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 23:14:26 +00:00
Fariborz Jahanian 353b33b2bb 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106247 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 23:00:29 +00:00
Tom Care f521d6e151 Bug 7394 - Fixed toString representation of Precisions in format strings.
M    include/clang/Analysis/Analyses/PrintfFormatString.h
M    lib/Analysis/PrintfFormatString.cpp


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106245 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 22:55:40 +00:00
Fariborz Jahanian 949bd4b611 Do not treat @selector as lvalue (unlike g++).
Patch by Nico Weber (pr7390).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106242 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 21:45:48 +00:00
Zhanyong Wan 0c05a1bae9 Improves RecursiveASTVisitor:
* refactors code in DEF_TRAVERSE_DECL() into
  TraverseDeclContextHelper() to reduce code bloat and facilitate
  reuse.
* makes the order of traversing a FunctionDecl (including its
  subclasses)'s children more natural: before the function parameters
  are visited after the function body; now they are visited after the
  function type and before the function body.
* fixes a double count for function return type and arguments.

Reviewed by chandlerc and csilvers.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106236 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 20:56:31 +00:00
Fariborz Jahanian 03b2960c14 Objective-c++ IRGen. Support for @selector expression as
an lvalue. Fixes PR7390.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106235 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 19:56:20 +00:00
Tom Care e4ee966316 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


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106233 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 19:00:27 +00:00
Douglas Gregor e2872d0bda 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 16:03:49 +00:00
Douglas Gregor 1ec8ef7cd6 Use UnaryOperator as the representation of dependent expressions when
no overloaded operators were found in scope, mirroring what we already
do for BinaryOperator.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106222 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 15:46:20 +00:00
Douglas Gregor 2390b62f3a Update CMake build system for ARM NEON generation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106220 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 15:17:41 +00:00
Craig Silverstein ea245e0ba4 Some fixes to type-visiting -- a few places where the type-name was
explicitly typed in the source, but we weren't recursing on it.  One
is new <type>, the other is <type>() (eg int()).

I also fixed the initializer parsing to parse on the syntactic
initializer list, not the semantic.  Usually they'll be identical, so
this won't affect much in practice, but keeps the AST as a syntax-tree
visitor.

Reviewed by chandlerc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106218 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 13:40:37 +00:00
Peter Collingbourne 3e31d90a84 Fix typo (test commit)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106217 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 12:39:05 +00:00
Gabor Greif 170e508001 fix some more gcc3.4 constness warnings
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106216 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 11:29:31 +00:00
Gabor Greif 40844a8b5a use typedef to make hack more transparent and also appease gcc3.4 constness warning
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106215 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 10:59:08 +00:00
Argyrios Kyrtzidis 7558cd00a5 Make sure the caching mechanism in Parser::ParseLexedMethodDefs is robust against the parser reading too few tokens.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106214 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 10:52:22 +00:00
Argyrios Kyrtzidis 36d36806f1 Make sure parens/braces/brackets are correctly balanced.
In a line like:

(;

the semicolon leaves Parser:ParenCount unbalanced (it's 1 even though we stopped looking for a right paren).
This may affect later parsing and result in bad recovery for parsing errors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106213 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 10:52:18 +00:00
Argyrios Kyrtzidis 2574f6f35a Don't ast-print the builtin __[u]int128_t.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106212 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 10:52:11 +00:00
Charles Davis 21e2a7e8d3 Mangle operator names in the Microsoft C++ Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106211 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 06:47:31 +00:00
Ted Kremenek a8166156a6 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106210 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 04:21:37 +00:00
Ted Kremenek 1a0c8b9183 Include the bug description in the report hash so that we can emit multiple bugs of the same
type at the same location.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 04:21:27 +00:00
Nate Begeman a23326b5c2 Generate arm_neon.inc in include/clang/Basic, which provides:
1. builtins definitions for BuiltinsARM.def
2. intrinsic validation code for SemaChecking

Unsure as to whether this is the best way to handle the make dependencies or not.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106208 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 04:17:01 +00:00
Nate Begeman d69ec16b1b Remove last of the bool shifts for MS VC++, patch by dimitry andric
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106206 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 02:26:59 +00:00
Sean Hunt 9c3e84ffe0 Comment Attr.td so people have a better understanding of what goes on.
Also removed the unused Aliases member.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106202 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 01:51:32 +00:00
Ted Kremenek 01cb1aa458 Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106196 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 01:12:20 +00:00
Ted Kremenek 252485e6bf Per conversation with Doug, remove two assertions in ParseLexedMethodDefs() that
didn't indicate violated invariants but that we weren't recovering well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106195 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:59:17 +00:00
Sean Hunt 6ec9debb2a Fix yet another CMake typo. I'm not quite sure how this succeeded locally now.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106193 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:51:27 +00:00
Sean Hunt 7028a17d30 Fix a typo in the previous commit I thought I'd fixed, but apparently didn't.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106189 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:42:32 +00:00
Sean Hunt ee6e4b4baa Update CMake build for new attribute changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106188 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:37:02 +00:00
Ted Kremenek 551bd1f919 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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106184 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:24:44 +00:00
Ted Kremenek 0e9910f8fe Implement RegionStoreManager::iterBindings(). This implementation only returns the base region in
the binding key instead of the region + offset.  It isn't clear if this is the best semantics, but most
clients will likely only care about simple bindings, or bindings to a particular variable.  We can
refine later if necessary.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106183 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:24:42 +00:00
Ted Kremenek 744b304457 Correctly return early from BasicStoreManager::iterBindings() when the BindingsHandler returns false.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106182 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-17 00:24:37 +00:00
Douglas Gregor e0cc047b19 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>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106175 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 23:45:56 +00:00
Sean Hunt 387475d0c1 Implement first TD-based usage of attributes.
Currently, there are two effective changes:

 - Attr::Kind has been changed to attr::Kind, in a separate namespace
   rather than the Attr class. This is because the enumerator needs to
   be visible to parse.
 - The class definitions for the C++0x attributes other than aligned are
   generated by TableGen.

The specific classes generated by TableGen are controlled by an array in
TableGen (see the accompanying commit to the LLVM repository). I will be
expanding the amount of code generated as I develop the new attributes system
while initially keeping it confined to these attributes.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106172 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 23:43:53 +00:00
Douglas Gregor f13ca06e57 Make the "extra ';' inside a struct or union" diagnostic more
precise. Fixes PR7336.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106170 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 23:08:59 +00:00
Douglas Gregor d6ab232bb3 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106167 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 23:00:59 +00:00
Douglas Gregor 1a15dae8be 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.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106161 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 22:31:08 +00:00
Ted Kremenek 13927a431d Extend format string type-checking to include '%p'. Fixes remaining cases PR 4468.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@106151 91177308-0d34-0410-b5e6-96231b3b80d8
2010-06-16 21:23:04 +00:00