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

6098 Коммитов

Автор SHA1 Сообщение Дата
Ted Kremenek 3687a5d83f Move version string generation (e.g., "clang 1.1 ...") to libBasic/Version.cpp, getClangFullVendorVersion().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94235 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 22:29:50 +00:00
Douglas Gregor c42fefa51f Improve content and structure of the Doxygen documentation for the
CIndex API. No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94234 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 22:29:16 +00:00
Ted Kremenek f7a96a3995 (1) Rename getClangSubversionRevision() to getClangRevision(), and
have it return a StringRef instead of an integer (to be more VCS
    agnostic).

(2) Add getClangFullRepositoryVersion(), which contains an
    amalgamation of the repository name and the revision.

(3) Change PCH to only emit the string returned by
    getClangFullRepositoryVersion() instead of also emitting the value
    of getClangSubversionRevision() (which has been removed).  This is
    functionally equivalent.

More cleanup to version string generation pending...



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94231 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 22:12:47 +00:00
Douglas Gregor b979034b10 Yet more CIndex API cleanup:
- Added more routines to manipulate/compare source locations and ranges
  - Switched clang_getCursor() over to take a CXSourceLocation rather
  than file/line/column.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94226 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 21:44:22 +00:00
Ted Kremenek 5b4ec63663 Rename pch::SVN_BRANCH_REVISION to pch::VERSION_CONTROL_BRANCH_REVISION.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94214 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:59:36 +00:00
Ted Kremenek 517e676b9e Rename getClangSubversionPath() -> getClangRepositoryPath() and have it return a StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94213 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 20:55:35 +00:00
Douglas Gregor 33e9abd210 Teach CIndex's cursor visitor to restrict its traversal to a specific
region of interest (if provided). Implement clang_getCursor() in terms
of this traversal rather than using the Index library; the unified
cursor visitor is more complete, and will be The Way Forward.

Minor other tweaks needed to make this work:
  - Extend Preprocessor::getLocForEndOfToken() to accept an offset
  from the end, making it easy to move to the last character in the
  token (rather than just past the end of the token).
  - In Lexer::MeasureTokenLength(), the length of whitespace is zero.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94200 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 19:49:59 +00:00
Zhongxing Xu b79b117d3b Process cast according to the cast kind. Prepare for more specific cast
handling (for C++). No functionality change for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94153 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 04:30:00 +00:00
Daniel Dunbar eec99100f0 Driver/Darwin: Update tool chain to use static clang_rt libraries provided by
compiler-rt. This tool chain now works on x86 and ARM, but isn't the x86 default
yet. 

This drastically cleans up the linker invocation, old invocation:
--
"/Developer/usr/bin/../libexec/gcc/i686-apple-darwin10/4.2.1/ld" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.6.0" "-weak_reference_mismatches" "non-weak" "-o" "a.out" "-lcrt1.10.6.o" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/x86_64" "-L/usr/lib/i686-apple-darwin10/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../../i686-apple-darwin10/4.2.1" "-L/usr/lib/gcc/i686-apple-darwin10/4.2.1/../../.." "t.o" "-lSystem" "-lgcc"
--

New invocation:
--
# For 10.6:
 "/usr/bin/ld" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.6.0" "-o" "a.out" "-lcrt1.10.6.o" "t.o" "-lSystem"
# For 10.4:
 "/usr/bin/ld" "-dynamic" "-arch" "x86_64" "-macosx_version_min" "10.4" "-o" "a.out" "-lcrt1.o" "t.o" "-lSystem" "-lgcc_s.10.4" "/Volumes/Data/ddunbar/llvm.obj.64/Debug/lib/clang/1.1/lib/darwin/libclang_rt.10.4.a"
--

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 03:38:14 +00:00
Douglas Gregor 1ef2fc1888 Teach the cursor visitor to walk all of the C and Objective-C
declarations that have enough source information to make such a walk
useful. This includes walking into variable initializers and enum
constants, the types behind typedefs, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94124 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 00:50:27 +00:00
Chris Lattner f45b646244 revert my patch for rdar://7520940 that warns when a published header
is #included with "foo.h" style syntax instead of framework syntax.
It produced too much noise.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-22 00:14:44 +00:00
John McCall 0380043d40 Due to local reversions and re-patching, I accidentally had multiple copies
of the 'payload' in this header.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94109 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 22:59:41 +00:00
Mike Stump 2d6ceab0ad Improve unreachable code warnings for with respect to dead functional casts in C++.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94106 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 22:12:18 +00:00
Ted Kremenek 71842cc07a Allocate the 'Protocols' array in ObjCInterfaceType and
ObjCObjectPointerType using the allocator associated with ASTContext.
Not only does this fix a memory leak, but it also makes these arrays
BumpPtrAllocated (in the typical case).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94090 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 19:22:34 +00:00
Fariborz Jahanian d8265b8383 Fixes a comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94088 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 17:39:43 +00:00
Fariborz Jahanian d0502407c1 Patch to implement rewriting of properties.
Fixes radar 7562952.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94087 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 17:36:00 +00:00
Douglas Gregor 7d0d40e588 Introduce type references into the C API, capturing references to
typedefs only (for now).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 16:28:34 +00:00
Mike Stump 4c45aa1b00 Speed up compilation by avoiding generating exceptional edges from
CallExprs as those edges help cause a n^2 explosion in the number of
destructor calls.  Other consumers, such as static analysis, that
would like to have more a more complete CFG can select the inclusion
of those edges as CFG build time.

This also fixes up the two compilation users of CFGs to be tolerant of
having or not having those edges.  All catch code is assumed be to
live if we didn't generate the exceptional edges for CallExprs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94074 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 15:20:48 +00:00
Mike Stump b978a441c7 Add infrastructure to add base initializers and member initializers to
the CFG.  WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94062 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-21 02:21:40 +00:00
Douglas Gregor b2cd487561 Stash a CXXUnit pointer into each cursor. This allows us to simplify
the interface to clang_visitChildren() by eliminating the
CXTranslationUnit pointer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94051 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 23:57:43 +00:00
Douglas Gregor f55254472e Yet more Doxygen-comment tweaking in the CIndex library.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94044 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 22:45:41 +00:00
Douglas Gregor 7f17376e09 Improve Doxygen documentation for the CIndex library, somewhat.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94042 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 22:28:27 +00:00
John McCall 7264fa161f Change LLVM/clang #includes to use quotes, not angle-brackets. Just a think-o
prompted by the #include <iterator> above.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94040 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 22:16:29 +00:00
Douglas Gregor 04d1dd476a Kill CXEntity and CXDecl. The first has never been used, while the
second has been wholly replaced by cursors.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94039 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 22:14:22 +00:00
John McCall 46460a68f6 First pass at collecting access-specifier information along inheritance paths.
Triggers lots of assertions about missing access information;  fix them.

Will actually consume this information soon.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94038 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:53:11 +00:00
Douglas Gregor 78205d4bad Kill some CXDecl-related APIs that have been superceded by
CXCursor-based APIs.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94037 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:45:58 +00:00
Douglas Gregor 68372aa4c5 Kill CXStmt. It isn't being used anywhere, and has no future.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94036 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:38:07 +00:00
Douglas Gregor 002a528ab0 Kill clang_loadDeclaration() and clang_loadTranslationUnit().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94034 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:37:00 +00:00
Daniel Dunbar d31351288e Use sizeof() instead of hard-coding a size for WrittenBuiltinSpecs, eek!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94024 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 21:13:31 +00:00
Douglas Gregor b1373d03e4 Introduce a new, cursor-based traversal function that visits the
children of a given cursor, regardless of what kind of cursor it
is. This is a generalization of clang_loadDeclaration and
clang_loadTranslationUnit that will also extent to statements,
expressions, etc.

As proof-of-concept, switched clang_loadDeclaration() from its own
visitor over to an instance of this traversal function internally.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94022 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 20:59:29 +00:00
Fariborz Jahanian 3ad230eb62 Settled rule on warning on unimplemented property in
category implementation when some implementations
are missing in the primary class implementation.
(fixes radar 6505200).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94014 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 19:36:21 +00:00
Chris Lattner 3ea5cf8889 reduce redundant are's
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94009 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 17:53:58 +00:00
Chandler Carruth fb26025575 Fix a typo pointed about by gabor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93997 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 07:43:54 +00:00
Chandler Carruth 103b71c37a Move the MacroBuilder utilitiy to its own header. Update references.
Comments and/or improvements to the documentation are welcome.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93982 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 06:13:02 +00:00
Chandler Carruth 8a32907d54 Fix a layering issue between Basic and FE by moving a utility class into Basic.
This isn't entirely satisfactory, as it seems an implementation detail, and
with nothing to do with TargetInfo. Suggestions on where to put this are
welcome.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93974 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 03:59:11 +00:00
Daniel Dunbar 225c41706d Driver: Lift clang resource directory computation to the Driver object.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93971 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 02:35:16 +00:00
John McCall b377c98af6 Make UnresolvedSet.h standalone.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93964 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 01:36:13 +00:00
Douglas Gregor 20d416c36b Attempt to improve CIndex Doxygen organization, although I can't actually test this locally
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93961 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 01:10:47 +00:00
John McCall eec51cf1ba Give UnresolvedSet the ability to store access specifiers for each declaration.
Change LookupResult to use UnresolvedSet.  Also extract UnresolvedSet into its
own header and make it templated over an inline capacity.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93959 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:46:10 +00:00
Douglas Gregor e0356b1083 Kill off clang_getDeclColumn, clang_getDeclExtent, clang_getDeclLine,
clang_getDeclSource, and clang_getDeclSourceFile; the cursor
equivalents are the way of the future.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93955 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:26:57 +00:00
Douglas Gregor 7eaa8ae869 Introduce a special cursor kind for the translation unit, to serve as
the root of the conceptual cursor hierarchy (just like we do with
declarations). This will be used when we get to unify
clang_loadTranslationUnit() and clang_loadDeclaration() into something
more generally useful.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93954 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:23:15 +00:00
Douglas Gregor 36103f4d8b CXCursor_UnexposedDecl to the first declaration kind
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93952 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-20 00:07:45 +00:00
Douglas Gregor e0ca4baa1d Kill CXCursor_ObjCSelectorRef, CXCursor_VarRef, CXCursor_FunctionRef,
and CXCursor_EnumConstantRef; they've been subsumed by expression
references, which do a much nicer job.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93947 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 23:25:01 +00:00
Douglas Gregor 97b9872d57 Extend the CIndex API with direct support for expressions and
statements, moving some of the more unnatural kinds of references
(VarRef, EnumConstantRef, etc.) over to the expressions. We can now
poke at arbitrary expressions and statements with, e.g.,
clang_getCursor() and get back useful information (e.g., source
ranges).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93946 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 23:20:36 +00:00
Mike Stump a3899eb5e3 Implement goto inside of blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93945 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 23:08:01 +00:00
John McCall 1d7d8d66ef The type of a compound literal expression is not necessarily the same as the
type which was syntactically written.  Fixes PR 6080.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93933 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:33:45 +00:00
Douglas Gregor e8c7043f6c Kill the unused and unnecessary CXCursor_MemberRef, twin to the
now-dead CXCursor_ObjCIvarRef.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93928 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:15:34 +00:00
Douglas Gregor 5a5ec3a318 Kill CXCursor_ObjCIvarRef. Such cursors could never be created, and
have been marked for death for a while.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93927 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:11:32 +00:00
Douglas Gregor 301221313b Introduce the notion of an "unexposed" declaration into the CIndex
API. This is a catch-all for any declaration known to Clang but not
specifically part of the CIndex API. We'll use the same approach with
expressions, statements, references, etc., as needed.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93924 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:07:56 +00:00
Mike Stump 079bd72439 Add CFG support for the start and end of scopes and infrastructure for
implicit destructor calls.  WIP.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93922 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 22:00:14 +00:00
Douglas Gregor 1db19dea8d Rework the CXSourceLocation and CXSourceRange APIs. They are now
opaque data structures accessed through the new functions
clang_getInstantiationLocation(), clang_getRangeStart(), and
clang_getRangeEnd(). The new API permits later extensions to introduce
new functions to allow CIndex clients to walk macro instantiations, if
we ever care.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93915 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 21:36:55 +00:00
Douglas Gregor b699866820 Eliminate cursor kinds used to express definitions. Instead, provide
CIndex functions that (1) map from a reference or declaration to the
corresponding definition, if available, and (2) determine whether a
given declaration cursor is also a definition. This eliminates a lot
of duplication in the cursor kinds, and maps more closely to the Clang
ASTs.

This is another API + ABI breaker with no deprecation. Yay, progress.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93893 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 19:34:47 +00:00
Zhongxing Xu c39b2bdd4c Fix a serious bug: Tmp3 is the wrong destination set. We should create a new
intermediate destination set Tmp4.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93873 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 09:25:53 +00:00
Douglas Gregor c5d1e9375d Introduce clang_getCursorReferenced, to get a cursor pointing at the
entity that a particular cursor references.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93830 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 01:20:04 +00:00
Douglas Gregor a7bde20f8c Implement clang_getCursorExtent, which provides a source range for the
cursor itself. In particular, for references this returns the source
range of the reference rather than the source range of the thing it
refers to.

Switch c-index-test from clang_getDeclExtent (which will eventually be
deprecated and removed) over to clang_getCursorExtent. The source
ranges we print for references now make sense; fix up the tests
appropriately.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93823 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-19 00:34:46 +00:00
John McCall ad2b804faf Move AccessSpecifier into the new Specifiers.h; fixes the layering violations
inherent in, well, pretty much every use of AccessSpecifier.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93804 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 23:21:37 +00:00
Douglas Gregor 547836fad9 Now that a reasonable deprecation cycle has passed, kill
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile() outright.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93801 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:48:04 +00:00
Douglas Gregor 98258afae6 Introduce clang_getCursorLocation(), which supercedes
clang_getCursorLine(), clang_getCursorColumn(),
clang_getCursorSource(), and clang_getCursorSourceFile(). Mark those 4
functions as deprecated and stop using them ourselves.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93800 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:46:11 +00:00
Chris Lattner 046c2277dc allow the HandlerComment callback to push tokens into the
preprocessor.  This could be used by an OpenMP implementation
or something.  Patch by Abramo Bagnara!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93795 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:35:47 +00:00
Douglas Gregor 3c7313d96c Clean up the CIndex API slightly.
Renamed CXSourceFileLine to CXSourceLocation and added a CXFile, to
better match Clang's SourceLocation. Teach clang_getDeclExtent to fill
in the CXFile properly.

Renamed CXSourceExtent to CXSourceRange, to better match Clang's
SourceLocation.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93783 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 22:13:09 +00:00
Daniel Dunbar 353052194f Add missing newline.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93767 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 20:55:52 +00:00
Douglas Gregor d038f361d2 float, double, and long double do need extra data in the
BuiltinTypeLoc structure. Thanks, Enea!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93763 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 20:37:56 +00:00
Ted Kremenek cf84aa46de Replace clang_getDeclUSR() with clang_getCursorUSR(). Also remove printing 'contexts' from c-index-test output; it wasn't helpful and was extremely brittle.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93760 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 20:23:29 +00:00
John McCall 42f56b5006 Preserve type source information in compound literal expressions.
Patch by Enea Zaffanella!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93752 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 19:35:47 +00:00
Mike Stump b7fd588ea9 Silence a control reaches end of function warning. Patch by Enea
Zaffanella.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93743 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 18:41:43 +00:00
Douglas Gregor ddf889a2ad Improve source-location information for builtin TypeLocs, from Enea
Zaffanella (with a couple of my tweaks).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93733 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 18:04:31 +00:00
Daniel Dunbar 80febb9876 Fix race condition in creating objdir.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93730 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 17:52:37 +00:00
Douglas Gregor ab8bbf4ebd Encoding calling conventions in the type system, from Charles Davis!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93726 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 17:14:39 +00:00
Zhongxing Xu 3ed04d3757 Add support for computing size in elements for symbolic regions obtained from
malloc().


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93722 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-18 08:54:31 +00:00
Sam Weinig ce757a7a1e Add PCH support for CXXStaticCastExpr, CXXDynamicCastExpr, CXXReinterpretCastExpr, CXXConstCastExpr and CXXFunctionalCastExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93658 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 21:21:01 +00:00
Douglas Gregor 79c2278a66 When we are instantiating a member function of a local class, be sure
to merge the local instantiation scope with the outer local
instantiation scope, so that we can instantiate declarations from the
function owning the local class. Fixes an assert while instantiating
Boost.MPL's BOOST_MPL_ASSERT_MSG.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93651 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 20:21:20 +00:00
Douglas Gregor 3db211b617 Improve location information for Objective-C category declarations. We
previously only had a single location (the @ in @interface); now we
know where the @ is (for the start of the declaration), where the
class name is (that's the normal "location" now for diagnostics), and
where the category name is. Also, eliminated the redundant "end"
location, since ObjCContainerDecl already has better @end information.

The only XFAIL'd test is temporary; will un-XFAIL-it once I've taught
CIndex how to use the new locations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93639 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 16:38:58 +00:00
Douglas Gregor 18df52bbb5 Keep track of the source locations for each protocol reference in
Objective-C classes, protocol definitions, forward protocol
declarations, and categories. This information isn't actually used
yet; that's coming next.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93636 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 15:02:53 +00:00
Ted Kremenek deb06bd356 Remove 'default' case in switch statement in clang_getCursorKindSpelling(). This identified a missing case (warned by the compiler) and identified that CXCursor_FirstDecl didn't actually correspond to the first decl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93622 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 02:02:09 +00:00
Tanya Lattner 41bdf0d35c The codegen for these builtins was removed long ago, but their definitions remained. Removing them totally.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93607 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-16 01:10:51 +00:00
Douglas Gregor 283cae37b0 Make CXCursor's data opaque.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93561 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 21:56:13 +00:00
John McCall 9d125033a9 Preserve type source information in explicit cast expressions.
Patch by Enea Zaffanella.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93522 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 18:39:57 +00:00
Ken Dyck a730583241 Convert the type of the LValue offset variable in APValue to CharUnits, moving
the LValue-related methods of APValue out of line to avoid header file leaching.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93512 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 12:37:54 +00:00
Ted Kremenek 8b9317186f Convert a few more uses of std::string& to llvm::StringRef.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93506 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-15 07:43:59 +00:00
Douglas Gregor 9edad9b618 When qualified lookup into the current instantiation fails (because it
finds nothing), and the current instantiation has dependent base
classes, treat the qualified lookup as if it referred to an unknown
specialization. Fixes PR6031.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93433 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14 17:47:39 +00:00
John McCall 651f3eec13 Improve overload diagnostics some more by calling out qualifier mismatches
for special diagnostics.  Unfortunately, the non-overload diagnostics are not
this good.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93420 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14 03:28:57 +00:00
John McCall e81e15ed0c Improve the diagnostic for bad conversions in overload resolution to talk
about 'object argument' vs. 'nth argument'.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93395 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-14 00:56:20 +00:00
John McCall 9f28614bf1 Perform format-expansion on %select results.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93377 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 23:58:20 +00:00
Douglas Gregor bca403c17b Banish the notion of a "rank" for code-completion results, since we
are no longer using it for anything. No intended functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93376 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 23:51:12 +00:00
Douglas Gregor c38c3e1e72 Code-completion for @public, @protected, @private, @package.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93361 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 21:54:15 +00:00
Douglas Gregor b6ac2451bf Whenever completing ordinary names for an Objective-C source, also
provide completions for @ keywords. Previously, we only provided
@-completions after an @ was actually typed, which is useful but
probably not the common case.

Also, make sure a few Objective-C 2.0 completions only show up when
Objective-C 2.0 support is enabled (the default).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93354 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 21:24:21 +00:00
John McCall cfb708c354 Add type source information for both kinds of typeof types.
Patch by Enea Zaffanella.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93344 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 20:03:27 +00:00
Ted Kremenek b89e8f64e6 Add 'referringDecl' field to CXCursor to prepare the way to better model declaration references from other delcarations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93343 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 19:59:20 +00:00
Fariborz Jahanian 7d957472ef Predefine __weak attribute when doing objective-c
rewriting for any target. (refixes radar 7530235).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93331 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 18:51:17 +00:00
Douglas Gregor 0efc2c1716 Reimplement constructor declarator parsing to cope with template-ids
that name constructors, the endless joys of out-of-line constructor
definitions, and various other corner cases that the previous hack
never imagined. Fixes PR5688 and tightens up semantic analysis for
constructor names.

Additionally, fixed a problem where we wouldn't properly enter the
declarator scope of a parenthesized declarator. We were entering the
scope, then leaving it when we saw the ")"; now, we re-enter the
declarator scope before parsing the parameter list.

Note that we are forced to perform some tentative parsing within a
class (call it C) to tell the difference between

  C(int); // constructor

and

  C (f)(int); // member function

which is rather unfortunate. And, although it isn't necessary for
correctness, we use the same tentative-parsing mechanism for
out-of-line constructors to improve diagnostics in icky cases like:

  C::C C::f(int); // error: C::C refers to the constructor name, but
                  // we complain nicely and recover by treating it as
                  // a type.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93322 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 17:31:36 +00:00
Sean Hunt a6c058dd75 Implement semantic checking for C++ literal operators.
This now rejects literal operators that don't meet the requirements.
Templates are not yet checked for.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93315 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 09:01:02 +00:00
Chris Lattner 52388f9aef diagnose invalid values of -ftabstop, patch by Christian Adaker!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93288 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 03:06:50 +00:00
Mike Stump fa6ef180c0 Add an unreachable code checker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93287 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 02:59:54 +00:00
Daniel Dunbar 0397af277e cc1: Factor out CompilerInstance::ExecuteAction which has the majority of the
clang -cc1 logic for running an action against a set of options.
 - This should make it easier to build tools that have a clang -cc1 like
   interface, but aren't actually part of clang -cc1.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93282 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:48:06 +00:00
John McCall 220ccbf2c9 Improve the reporting of non-viable overload candidates by noting the reason
why the candidate is non-viable.  There's a lot we can do to improve this, but
it's a good start.  Further improvements should probably be integrated with the
bad-initialization reporting routines.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93277 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-13 00:25:19 +00:00
Ted Kremenek c50277f748 Rename clang_getUSR() -> clang_getDeclUSR(). For now we take a CXDecl instead of a CXEntity.
Enhance USR generation a bit with support for records.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93267 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 23:33:42 +00:00
Douglas Gregor d1e4d9bfd5 Don't emit string-comparison or self-comparison warnings in
unevaluated contexts, because they only matter for code that will
actually be evaluated at runtime.

As part of this, I had to extend PartialDiagnostic to support fix-it
hints.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93266 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 23:18:54 +00:00
Douglas Gregor 84d0a19828 Improve recovery for template-ids whose template-name doesn't actually
name a template, when they occur in a base-specifier. This is one of
the (few) places where we know for sure that an identifier followed by
a '<' must be a template name, so we can diagnose and recover well:

test/SemaTemplate/dependent-base-classes.cpp:9:16: error: missing
'template'
      keyword prior to dependent template name 'T::apply'
struct X1 : T::apply<U> { }; // expected-error{{missing 'template' ...
               ^
               template 
test/SemaTemplate/dependent-base-classes.cpp:12:13: error: unknown
template name
      'vector'
struct X2 : vector<T> { }; // expected-error{{unknown template name
'vector'}}
            ^
2 diagnostics generated.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93257 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 21:28:44 +00:00
Chris Lattner 7ef655a788 implement PR6004, warning about divide and remainder by zero.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93256 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 21:23:57 +00:00
Chris Lattner a1e1dc77e9 implement PR6007, diagnosing invalid attribute((section))
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93255 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 20:58:53 +00:00
Chandler Carruth 5535c38a2f Fix the CodeGen half of PR5911 by changing reference initialization to
correctly look through arrays to see cv-qualifiers. Also enhances the routine
for doing this to preserve more type sugaring for diagnostics.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93252 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 20:32:25 +00:00
John McCall 3c80f573df Reorganize some of the code to note overload candidates. Improves the
fidelity with which we note them as functions/constructors and templates
thereof.  Also will be helpful when reporting bad conversions (next).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93224 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 02:15:36 +00:00
Ted Kremenek 1fc00e6e49 Change clang_getUSR() to return a CXString instead of a 'const char *'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93213 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-12 00:38:53 +00:00
Ted Kremenek 3172383341 CIndex:
- Remove unused (and unimplemented) clang_getDeclarationName().
- Remove unused (and unimplemented) clang_getEntity().
- Add clang_getEntityFromDecl(): maps from a CXDecl to a CXEntity)
- Add clang_getDeclaration(): maps from a (CXEntity, CXTranslationUnit) to a CXDecl).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93209 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 23:56:39 +00:00
Benjamin Kramer e45c149996 Avoid use of deprecated functions (CStrInCStrNoCase and StringsEqualNoCase).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93175 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 19:46:28 +00:00
Ken Dyck aa8741a1db Change return type of getObjCEncodingTypeSize() to CharUnits as the units are in characters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93171 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 19:19:56 +00:00
Douglas Gregor 58408bc4ea Tighten up the "cannot return array or function type" diagnostic to
say either "array type" or "function type", whichever it is. No reason
to make the user guess.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93164 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 18:46:21 +00:00
Douglas Gregor 48026d26fb Implement name lookup for conversion function template specializations
(C++ [temp.mem]p5-6), which involves template argument deduction based
on the type named, e.g., given

  struct X { template<typename T> operator T*(); } x;

when we call

  x.operator int*();

we perform template argument deduction to determine that T=int. This
template argument deduction is needed for template specialization and
explicit instantiation, e.g.,

  template<> X::operator float*() { /* ... */ }

and when calling or otherwise naming a conversion function (as in the
first example). 

This fixes PR5742 and PR5762, although there's some remaining ugliness
that's causing out-of-line definitions of conversion function
templates to fail. I'll look into that separately.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93162 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 18:40:55 +00:00
Ken Dyck 199c3d6cd1 Roll out ASTContext::getTypeSizeInChars(), replacing instances of
"ASTContext::getTypeSize() / 8". Replace [u]int64_t variables with CharUnits
ones as appropriate. 

Also rename RawType, fromRaw(), and getRaw() in CharUnits to QuantityType, 
fromQuantity(), and getQuantity() for clarity.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93153 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 17:06:35 +00:00
Sebastian Redl e27d87ff27 Make Clang complain about taking the address of an unqualified member function. Fixes PR5985.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93150 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 15:56:56 +00:00
Ted Kremenek c50e6df965 Switch RegionStore over to using <BaseRegion+raw offset> to store
value bindings.  Along with a small change to OSAtomicChecker, this
resolves <rdar://problem/7527292> and resolves some long-standing
issues with how values can be bound to the same physical address by
not have the same "key".  This change is only a beginning; logically
RegionStore needs to better handle loads from addresses where the
stored value is larger/smaller/different type than the loaded value.
We handle these cases in an approximate fashion now (via
CastRetrievedVal and help in SimpleSValuator), but it could be made
much smarter.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93137 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-11 02:33:26 +00:00
Sean Hunt 8c723404c3 Do not parse hexadecimal floating point literals in C++0x mode because they are
incompatible with user-defined literals, specifically with the following form:

  0x1p+1

The preprocessing-number token extends only as far as the 'p'; the '+' is not
included. Previously we could get away with this extension as p was an invalid
suffix, but now with user-defined literals, 'p' might well be a valid suffix
and we are forced to consider it as such.

This patch also adds a warning in non-0x C++ modes telling the user that
this extension is incompatible with C++0x that is enabled by default
(previously and with other languages, we warn only with a compliance
option such as -pedantic).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93135 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 23:37:56 +00:00
Douglas Gregor 01dfea02d1 Improve code completion by introducing patterns for the various C and
C++ grammatical constructs that show up in top-level (namespace-level)
declarations, member declarations, template declarations, statements,
expressions, conditions, etc. For example, we now provide a pattern
for

  static_cast<type>(expr)

when we can have an expression, or

  using namespace identifier;

when we can have a using directive.

Also, improves the results of code completion at the beginning of a
top-level declaration. Previously, we would see value names (function
names, global variables, etc.); now we see types, namespace names,
etc., but no values.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93134 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 23:08:15 +00:00
Anton Korobeynikov fc5d513335 Make clone() method out-of-line for Attr classes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93120 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 14:38:13 +00:00
Anton Korobeynikov 82d0a418c8 Generalize target weirdness handling having proper layering in mind:
1. Add helper class for sema checks for target attributes
 2. Add helper class for codegen of target attributes

As a proof-of-concept - implement msp430's 'interrupt' attribute.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93118 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 12:58:08 +00:00
Chris Lattner a139481e62 stringref'ize a bunch of filename handling logic. Much
nicer than passing around two const char*'s.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93094 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 01:35:12 +00:00
Chris Lattner 804f652719 implement rdar://7520940: published framework headers should
import other headers within the same framework with the full
framework path, not with a relative include.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93083 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-10 00:24:58 +00:00
Chris Lattner 124fca533d implement -ftabstop=width, patch by Christian Adåker
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93078 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 21:54:33 +00:00
Chris Lattner e6e8b5af0d make missing prototypes warn by default in c99 mode like GCC does,
rdar://7083878


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93073 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 20:43:38 +00:00
Benjamin Kramer a99927774d Use MacroBuilder for TargetDefines instead of std::vector.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93058 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 17:55:51 +00:00
Benjamin Kramer b1b5b901ca Move MacroBuilder into Frontend/Utils.h and clean it up a bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93057 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 17:43:21 +00:00
Zhongxing Xu bc37b8dd99 When binding an rvalue to a reference, create a temporary object. Use
CXXObjectRegion to represent it. 

In Environment, lookup a literal expression before make up a value for it.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93047 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-09 09:16:47 +00:00
Ted Kremenek 6ab9db10c5 For now, add back clang_getDeclSource().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93003 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 17:11:32 +00:00
Dan Gohman c31176d5eb Use -fno-math-errno by default, and remove the IsMathErrnoDefault
targethook, which is no longer being used. This fixes PR5971.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92987 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 02:20:44 +00:00
Douglas Gregor 827feec561 Improve the fix-its for -Wparentheses to ensure that the fix-it
suggestions follow recovery. Additionally, add a note to these
diagnostics which suggests a fix-it for changing the behavior to what
the user probably meant. Examples:

t.cpp:2:9: warning: & has lower precedence than ==; == will be evaluated first
      [-Wparentheses]
  if (i & j == k) {
        ^~~~~~~~
          (     )
t.cpp:2:9: note: place parentheses around the & expression to evaluate it first
  if (i & j == k) {
        ^
      (    )

t.cpp:14:9: warning: using the result of an assignment as a condition
without
      parentheses [-Wparentheses]
  if (i = f()) {
      ~~^~~~~
      (      )
t.cpp:14:9: note: use '==' to turn this assignment into an equality
comparison
  if (i = f()) {
        ^
        ==




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92975 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-08 00:20:23 +00:00
Douglas Gregor 828a197317 Add an "implicit" bit to CXXThisExpr, so that we can track
implicitness without losing track of the (logical or actual) location
where "this" would occur in the source.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92958 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 23:12:05 +00:00
Ted Kremenek 6a12a14a52 Fix typo: rename Rewriter::getRewritenText() -> Rewriter::getRewrittenText().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92922 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 18:00:35 +00:00
John McCall 1eb3e1003d Improve the lead diagnostic for C++ object subscript expressions with
no viable overloads.  Use a different message when the class provides
no operator[] overloads at all; use it for operator(), too.

Partially addresses PR 5900.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92894 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 02:04:15 +00:00
Ted Kremenek 782f2f52b7 Change ObjCContainerDecl to contain the entire range for the '@end'
piece of the declaration.  The '@' and the 'end' are separate tokens,
and require two SourceLocations to accurately track.

This change was motivated because ObjCContainerDecl::getSourceRange()
would previously not return the entire range of the declaration (the
'end' would be left off).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92891 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 01:20:12 +00:00
Douglas Gregor 0d535c89c5 When we typo-correct a base class initializer, point to the base class
specifier that we corrected to.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92878 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-07 00:26:25 +00:00
Ted Kremenek d8210650ed Change clang_getDeclExtent() to have the endpoint point to the last character in the last token.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92869 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 23:43:31 +00:00
Douglas Gregor 319d57f216 Move the allocation of designators in DesignatedInitExpr to the
ASTContext. Fixes <rdar://problem/7495428>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92867 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 23:17:19 +00:00
John McCall b1622a1fd7 Improve the diagnostics used to report implicitly-generated class members
as parts of overload sets.  Also, refer to constructors as 'constructors'
rather than functions.

Adjust a lot of tests.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92832 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 09:43:14 +00:00
Daniel Dunbar 3aacd53816 Add missing CINDEX_LINKAGE.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92827 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-06 06:51:48 +00:00
John McCall cd7a445c6b Add Expr::EvaluateAsBooleanCondition(), which does unprincipled folding to
try to evaluate an expression as a constant boolean condition.  This has
the same intended semantics as used in folding conditional operators.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92805 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:42:56 +00:00
Ted Kremenek 817db7cb9b Remove deprecated function 'clang_getDeclSource()'. Use 'clang_getDeclFile()' instead.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92803 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:21:30 +00:00
Ted Kremenek fe6fd3d41a Add C API hook 'clang_getDeclExtent()', which returns the source extent of a declaration. This implements <rdar://problem/7280072>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92802 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 23:18:49 +00:00
Ted Kremenek 1b6869a183 Split (mostly nonexistent) USR code out from the main CIndex logic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92789 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 22:06:45 +00:00
Nate Begeman edcfc41114 Allow clang to pass -x cl through to compiler driver.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92686 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 06:00:15 +00:00
Mike Stump 2849734790 Disallow captured arrays in blocks as well. Radar 7438948.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92677 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 03:10:36 +00:00
Mike Stump 0d6fd570e5 Disallow capturing vlas inside blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92676 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 02:56:35 +00:00
Ted Kremenek de0d263101 Make static analysis support for C++ 'this' expression context-sensitive. Essentially treat 'this' as a implicit parameter to the method call, and associate a region with it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92675 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 02:18:06 +00:00
Chris Lattner 6ffe643322 fix a bug mike noticed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92559 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 01:23:25 +00:00
Ted Kremenek 32a58084a4 Remove references to 'Checker' and 'GRTransferFuncs' from
GRStateManager.  Having these references was an abstraction violation,
as they really should only be known about GRExprEngine.

This change required adding a new 'ProcessAssume' callback in
GRSubEngine.  GRExprEngine implements this callback by calling
'EvalAssume' on all registered Checker objects as well as the
registered GRTransferFunc object.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92549 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-05 00:15:18 +00:00
Mike Stump 3b11fd3b52 Remember if the AsmStmt came from Microsoft-style inline assembly code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92526 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 22:37:17 +00:00
Douglas Gregor 442471309f Make sure to use ASTContext::getAs*ArrayType() when decomposing array
types. Fixes APFloat.cpp compilation failure.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92523 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 22:11:45 +00:00
Daniel Dunbar f8c381fff1 Add missing newline (which breaks MSVC build???)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92522 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 22:04:01 +00:00
Douglas Gregor 88a35862fb Teach Preprocessor::macro_begin/macro_end to lazily load all macro
definitions from a precompiled header. This ensures that
code-completion with macro names behaves the same with or without
precompiled headers.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92497 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 19:18:44 +00:00
Douglas Gregor 95ff742380 When declaring an Objective-C implementation without a corresponding
interface, suggest correction of typos. For example, given:

  @interface NSString
  @end

  @implementation NSstring
  @end

we'll warn with:

t.m:4:19: warning: cannot find interface declaration for 'NSstring';
    did you mean 'NSString'?
  @implementation NSstring
                  ^

However, since this is just a warning, we don't provide a fix-it
hint. Good idea, Ted!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92488 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-04 17:27:12 +00:00
Douglas Gregor f06cdae9c6 Implement typo correction for a variety of Objective-C-specific
constructs:

  - Instance variable lookup ("foo->ivar" and, in instance methods, "ivar")
  - Property name lookup ("foo.prop")
  - Superclasses
  - Various places where a class name is required
  - Protocol names (e.g., id<proto>)

This seems to cover many of the common places where typos could occur.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92449 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-03 18:01:57 +00:00
Douglas Gregor c171e3b192 Typo correction for C99 designated field initializers, e.g.,
test/FixIt/typo.c:19:4: error: field designator 'bunds' does not refer to any
      field in type 'struct Window'; did you mean 'bounds'?
  .bunds.
   ^~~~~
   bounds



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92376 91177308-0d34-0410-b5e6-96231b3b80d8
2010-01-01 00:03:05 +00:00
Anders Carlsson be2e205add Make sure that an overriding return type is complete before checking if it's covariant. Fixes PR5920.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92365 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 18:34:24 +00:00
Douglas Gregor fe0241e31d Typo correction for C++ base and member initializers, e.g.,
test/FixIt/typo.cpp:41:15: error: initializer 'base' does not name a non-static
      data member or base class; did you mean the base class 'Base'?
  Derived() : base(),
              ^~~~
              Base
test/FixIt/typo.cpp:42:15: error: initializer 'ember' does not name a non-static
      data member or base class; did you mean the member 'member'?
              ember() { }
              ^~~~~
              member



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92355 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 09:10:24 +00:00
Douglas Gregor bfea239caf Typo correction for template names, e.g.,
typo.cpp:27:8: error: no template named 'basic_sting' in namespace 'std'; 
    did you mean 'basic_string'?
  std::basic_sting<char> b2;
  ~~~~~^~~~~~~~~~~
       basic_string



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92348 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 08:11:17 +00:00
Zhongxing Xu b94b81a9ab Let constraint manager inform checkers that some assumption logic has happend.
Add new states for symbolic regions tracked by malloc checker. This enables us
to do malloc checking more accurately. See test case.

Based on Lei Zhang's patch and discussion.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92342 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 06:13:07 +00:00
Douglas Gregor bb092bafa9 Implement typo correction for id-expressions, e.g.,
typo.cpp:22:10: error: use of undeclared identifier 'radious'; did
      you mean 'radius'?
  return radious * pi;
         ^~~~~~~
         radius

This was super-easy, since we already had decent recovery by looking
for names in dependent base classes.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92341 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-31 05:20:13 +00:00
Zhongxing Xu f2017d13eb Fix a comment.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92314 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30 21:24:23 +00:00
Douglas Gregor 546be3c5c0 Typo correction for type names when they appear in declarations, e.g., given
tring str2;

we produce the following diagnostic + fix-it:

typo.cpp:15:1: error: unknown type name 'tring'; did you mean 'string'?
  tring str2;
  ^~~~~
  string


To make this really useful, we'll need to introduce typo correction in
many more places (wherever we do name lookup), and implement
declaration-vs-expression heuristics that cope with typos
better. However, for now this will handle the simple cases where we
already get good "unknown type name" diagnostics.

The LookupVisibleDecls functions are intended to be used by code
completion as well as typo correction; that refactoring will happen
later.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92308 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30 17:04:44 +00:00
Chandler Carruth e724246b9f More fixes to the handling of CVR-comparisons on array types. Adds a method to
QualType to get CVR-qualifiers through array types, and switches the primary
comparison methods to use it. This may allow simplifying some of the callers of
getUnqualifiedArrayType.

Also fix the normalizing of CV-qualification during template deduction to
normalize through arrays and allow a more qualified deduced array type. This
fixes PR5911.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92289 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30 04:10:01 +00:00
John McCall 5126fd0dd9 Typedefs can be redeclared. That seems like something we should record in
the AST lest we run into some crazy canonicalization bug like PR5874.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92283 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30 00:31:22 +00:00
Eli Friedman 2333f7727f Make sure to explicitly pass type/value dependence to Expr constructor. This
caught several cases where we were not doing the right thing. I'm
not completely sure all cases are being handled correctly, but this should
be an improvement.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92281 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-30 00:13:48 +00:00
Chandler Carruth 28e318cc60 Correctly refer to element CVR qualifications when determining if a type is
more or less cv-qualified than another during implicit conversion and overload
resolution ([basic.type.qualifier] p5). Factors the logic out of template
deduction and into the ASTContext so it can be shared.

This fixes several aspects of PR5542, but not all of them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92248 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 07:16:59 +00:00
Anders Carlsson f5f7d864f5 Get rid of FixedWidthIntType, as suggested by Chris and Eli.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92246 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-29 07:07:36 +00:00
Zhongxing Xu 2d3dfd70ee Adjust indentation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92205 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-28 06:52:51 +00:00
Benjamin Kramer 0235d1510d Make sure operator new[] and operator delete[] match. This will hopefully silence 3 remaining MSVC warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92163 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-25 17:06:27 +00:00
Douglas Gregor 7557a1348d Egregious, disgusting workaround for PR5866. We need to rework how we
keep track of friends within templates, which will provide a real for
PR5866. For now, this makes sure we don't do something entirely stupid
with friends of specializations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92143 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 20:56:24 +00:00
John McCall 6675586c70 Tweak the text of several main() diagnostics and punch a hole specifically for
Darwin's sekrit fourth argument.  This should probably be factored to
let targets make target-specific decisions about what main() should look like.

Fixes rdar://problem/7414990
or if different platforms have radically different ideas of what they want in



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92128 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 09:58:38 +00:00
John McCall 94c939dc1d Diagnose out-of-bounds floating-point constants. Fixes rdar://problem/6974641
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92127 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 09:08:04 +00:00
Zhongxing Xu 62d399e188 As Ted suggested, record the callsite information with the StackFrameContext.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92121 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 03:34:38 +00:00
Ted Kremenek bfbcefb7e9 Enhance dataflow analyses to recognize branch statements in the CFG used as hooks for the initialization of condition variables.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92119 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 02:40:30 +00:00
Zhongxing Xu 598278bee8 Inter-procedural analysis: now we can return from the callee.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92116 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 02:25:21 +00:00
Ted Kremenek 6281213d87 Fix bug I just introduced in ForStmt::child_end() where we could iterate off into garbage values.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92115 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 01:59:46 +00:00
Ted Kremenek f0d975f25b Coelesce 'DoDestroy()' methods in Stmt.cpp, and modify the child_iterator returned by ForStmt to include the initializer of the condition variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92112 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 01:48:39 +00:00
Ted Kremenek 7d02b8c3be Modify WhileStmt::child_begin()/child_end() to include the initializer for the condition variable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92104 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 00:54:19 +00:00
Ted Kremenek fcfb503c28 Teach GRExprEngine to handle the initialization of the condition variable of a SwitchStmt.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92102 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-24 00:40:03 +00:00
Ted Kremenek 35628d1f17 Add StmtIterator support for iterating over both the condition
variable initializer and the other expressions in an IfStmt.

This change required adding a 'DoDestroy()' method for IfStmt that did
not include destroying the initializer (since that is owned by the
VarDecl).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92089 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 23:38:34 +00:00
Douglas Gregor 036aed1866 When we see a CXXDefaultArgExpr during template instantiation, rebuild
the default argument so that we're sure to mark any referenced
declarations. This gets us another little step closer to fixing
PR5810.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92078 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 23:03:06 +00:00
Ted Kremenek b03f630a5d Increase StmtIterator size by one pointer (separating out the Stmt** from the union including Decl* and Decl**).
This change is setup for adding StmtIterator support for condition variables in IfStmt, WhileStmt, etc.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92070 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 22:31:49 +00:00
Douglas Gregor 765ccba920 Diagnose the use of incomplete types in C++ typeid expressions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92045 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 21:06:06 +00:00
Chris Lattner 4718e67ca9 update comments
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92022 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 19:08:19 +00:00
Chris Lattner a3b089e062 switch -Werror/-Wfatal-errors error conditions to use diagnostics instead
of printf, patch by Christian Adaker!


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92019 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 18:53:37 +00:00
Douglas Gregor 65222e82d9 When using a default function argument for a function template (or
member function thereof), perform the template instantiation each time
the default argument is needed. This ensures that
  (1) We get different CXXTemporary objects for each instantiation, and
  (2) Any other instantiations or definitions triggered by the
  instantiation of the default argument expression are guaranteed to
  happen; previously, they might have been suppressed, e.g., because
  they happened in an unevaluated context.

This fixes the majority of PR5810. However, it does not address the
problem where we may have multiple uses of the same CXXTemporary
within an expression when the temporary came from a non-instantiated
default argument expression.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92015 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 18:19:08 +00:00
Kovarththanan Rajaratnam 49ac8e63a0 Remove RewriteBlocks. It has been superseded by RewriteObjC
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92014 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 18:03:34 +00:00
Douglas Gregor ab470d1cc2 Don't disable smart pointers, silly
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92009 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 17:42:06 +00:00
Douglas Gregor e1a5c17bff Fix DISABLE_SMART_POINTERS build
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92008 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 17:40:29 +00:00
Zhongxing Xu 3ff8481f4b Migrate the call inliner to the Checker interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91991 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 08:56:18 +00:00
Ted Kremenek e7809d4941 Add 'DeclStmt::DoDestroy()' which doesn't actually recurse over its child expressions (via StmtIterator), as those expressions are owned by the Decls and Types (which are destroyed elsewhere). This fixes a crasher reported in <rdar://problem/7487294>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91990 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 08:56:00 +00:00
Ted Kremenek 61dfbecd8e Add CFG support for the condition variable that can appear in IfStmts in C++ mode.
Add transfer function support in GRExprEngine for IfStmts with initialized condition variables.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91987 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 04:49:01 +00:00
Ted Kremenek e383768f7f Fix CXXConstructExpr::getSourceRange() to not include the source ranges of CXXDefaultArgExprs when computing its range (since these expressions have no source range, and using them will make the encompassing range invalid).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91984 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 04:00:48 +00:00
Ken Dyck 775f2eb491 Remove CharUnits::toString() to eliminate dependence on <string>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91978 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 02:44:11 +00:00
Ted Kremenek a5083e6ab5 Add assertion to check for valid source ranges.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91966 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 01:09:59 +00:00
Daniel Dunbar 1bda434673 Driver: Drop ToolChain::getHost()
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91960 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 00:46:38 +00:00
Ted Kremenek 949bdb43bf Add basic support for analyzing CastExprs as lvalues.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91952 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-23 00:26:16 +00:00
Nuno Lopes f857798fa7 warn when attribute warn_unused_result is applied to void functions.
while at it, remove an outdated FIXME

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91946 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 23:59:52 +00:00
Daniel Dunbar f3601388f2 Driver: When linking, don't warn about unused arguments which are obviously only
used during compilation.
 - There is no easy way to define this group properly, unfortunately, and maybe
   this is a losing strategy. For now this is unambiguous more friendly, though.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91940 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 23:19:32 +00:00
Chris Lattner e663c72006 implement -W[no-]fatal-errors, patch by Christian Adåker!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91938 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 23:12:53 +00:00
Chris Lattner aae57c21de accept -Wcomments as an alias for -Wcomment, PR5855
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91929 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 22:29:12 +00:00
Ted Kremenek 38ac4f504b Add transfer functions support for visiting an Objective-C message expression as an lvalue when the return type is a C++ reference.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91926 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 22:13:46 +00:00
Ken Dyck bdc601b196 Move the implementation of ASTContext::getTypeSizeInChars() to the .cpp file to
avoid #including CharUnits.h in ASTContext.h.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91903 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 14:23:30 +00:00
John McCall a236a55847 Stop diagnosing the use of inner classes as friends. ddunbar asked whether
this was useful, and on review Doug and I decided it was probably on the level
of a bug in the standard and therefore not worth a warning even in -pedantic.
If someone disagrees and urgently wants clang++ to warn about this in strict
c++98 mode, we can talk about it.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91868 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 00:59:39 +00:00
Douglas Gregor 9e9199d864 Eliminate the ASTContext argument to CXXConstructorDecl::isCopyConstructor, since the context is available in the Decl
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91862 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-22 00:34:07 +00:00
Daniel Dunbar a91320b8af ARM: Honor -mfpu= and set __VFP_FP__ and __ARM_NEON__ "correctly".
- Correctly is in quotes, because we are following what I interpreted as GCC's
   intent (which diverges from practice, naturally).
 - Also, fix the arch define for arm1136jf-s.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91855 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 23:28:17 +00:00
Douglas Gregor 4b52e25f3b When a template-id refers to a single function template, and the
explicitly-specified template arguments are enough to determine the
instantiation, and either template argument deduction fails or is not
performed in that context, we can resolve the template-id down to a
function template specialization (so sayeth C++0x
[temp.arg.explicit]p3). Fixes PR5811.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91852 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 23:17:24 +00:00
Daniel Dunbar ee788e70fc Add ToolChain::getDriver() and use it instead of going through the HostInfo
object.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91830 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-21 18:54:17 +00:00
Nuno Lopes d20254f287 fix PR4010: add support for the warn_unused_result for function pointers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91803 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-20 23:11:08 +00:00
John McCall f936815933 Don't inject the class name until that magical lbrace.
Because of the rules of base-class lookup* and the restrictions on typedefs, it
was actually impossible for this to cause any problems more serious than the
spurious acceptance of
  template <class T> class A : B<A> { ... };
instead of
  template <class T> class A : B<A<T> > { ... };
but I'm sure we can all agree that that is a very important restriction which
is well worth making another Parser->Sema call for.

(*) n.b. clang++ does not implement these rules correctly;  we are not ignoring
    non-type names



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91792 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-20 07:58:13 +00:00
John McCall bd0dfa5c37 Parse base specifiers within the scope of the class. This is possibly not
quite right;  I'll come back to it later.  It does fix PR 5741.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91789 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 21:48:58 +00:00
Daniel Dunbar 6ecc0b5000 Remove another ';' after method definition.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91781 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 18:58:59 +00:00
Daniel Dunbar 7177dee8ae Remove ';' after method definition. Noticed by clang++, which one would think
would have a higher respect for its own code. This is getting old, is this
warning really adding value?

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91779 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 17:50:07 +00:00
John McCall 7a1dc562d4 Refactor to remove more dependencies on PreDeclaratorDC. I seem to have made
the redeclaration problems in the [temp.explicit]p3 testcase worse, but I can
live with that;  they'll need to be fixed more holistically anyhow.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91771 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 10:49:29 +00:00
Anders Carlsson 17ef1660b2 Fix tyop.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91761 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 06:37:03 +00:00
Eli Friedman 65889f374c Some small Builtins.def improvements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91758 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 05:23:20 +00:00
Daniel Dunbar b93292ab7f Targets: Allow CreateTargetInfo to mutate the target features.
- In particular, it can claim features for itself instead of always passing them on to LLVM.
 - This allows using the target features as a generic mechanism for passing target specific options to the TargetInfo instance, which may need them for initializing preprocessor defines, etc.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91753 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 03:30:57 +00:00
Douglas Gregor 7abfbdbc97 Switch more of Sema::CheckInitializerTypes over to
InitializationSequence. Specially, switch initialization of a C++
class type (either copy- or direct-initialization). 

Also, make sure that we create an elidable copy-construction when
performing copy initialization of a C++ class variable. Fixes PR5826.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91750 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 03:01:41 +00:00
Anders Carlsson 29f1a6070a Correctly initialize the PrimaryBaseInfo if a base is null. Fixes PR5832.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91748 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-19 02:13:41 +00:00
Ken Dyck c3c90b25cf Add and tidy doxygen comments and move implementation of toString() to newly
created CharUnits.cpp.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91719 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 21:51:03 +00:00
Ted Kremenek 53287518f6 Enhance GRExprEngine::VisitCallExpr() to be used in an lvalue context. Uncovered a new failing test case along the way, but we're making progress on handling C++ references in the analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91710 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 20:13:39 +00:00
Daniel Dunbar 5231eaa5f5 Use System/DataTypes.h, stdint.h isn't portable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91707 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 20:00:49 +00:00
Douglas Gregor ff5ce6eefc Extend code-completion results with the type of each result
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91702 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 18:53:37 +00:00
Daniel Dunbar eac7c53f16 ARM: Fix predefines (__ARM_ARCH_..., __REGISTER_PREFIX).
- This should be done leveraging the backend, but I'm a little refactored
   out. I'll fix it one day, I promise.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91700 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 18:42:37 +00:00
Douglas Gregor ec6762c709 Change clang_codeComplete API to return the results in a structure on
the heap, so that clients are not forced to copy the results during
the initial iteration. A separate clang_disposeCodeCompleteResults
function frees the returned results.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91690 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 16:20:58 +00:00
Ken Dyck 4273f7068f Change the return type of ASTContext::getTypeSizeInChars() from uint64_t to the
new opaque value type, CharUnits. This will help us avoid accidentally mixing 
quantities that are in bit and character units.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91689 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 15:55:54 +00:00
Ken Dyck cc906ef220 Rename getByteSize() and getTypeSizeInBytes() in ASTContext to getCharWidth()
and getTypeSizeInChars() to reflect their basis in character type units, not
that of a possibly independent architecture-specific byte.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91688 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 15:24:05 +00:00
Ken Dyck 6443713788 Initial implementation of CharUnits, an opaque value class for representing
sizes, offsets, and alignments in character units.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91683 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 13:39:46 +00:00
Daniel Dunbar 38b48afd33 clang -cc1: Rename -mcpu to -target-cpu to match other target options and not alias driver/backend option.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91671 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 06:30:12 +00:00
Douglas Gregor 18ef5e28a9 Switch the initialization required by return statements over to the
new InitializationSequence. This fixes some bugs (e.g., PR5808),
changed some diagnostics, and caused more churn than expected. What's
new:

  - InitializationSequence now has a "C conversion sequence" category
    and step kind, which falls back to
  - Changed the diagnostics for returns to always have the result type
    of the function first and the type of the expression second.
    CheckSingleAssignmentConstraints to peform checking in C. 
  - Improved ASTs for initialization of return values. The ASTs now
    capture all of the temporaries we need to create, but
    intentionally do not bind the tempoary that is actually returned,
    so that it won't get destroyed twice.
  - Make sure to perform an (elidable!) copy of the class object that
    is returned from a class.
  - Fix copy elision in CodeGen to properly see through the
    subexpressions that occur with elidable copies.
  - Give "new" its own entity kind; as with return values and thrown
    objects, we don't bind the expression so we don't call a
    destructor for it.

Note that, with this patch, I've broken returning move-only types in
C++0x. We'll fix it later, when we tackle NRVO.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91669 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 05:02:21 +00:00
Daniel Dunbar f2d8b9f967 Add -dwarf-debug-flags, which provides a way to embed the cc1 level options used
to compile a translation unit into the debug info for that file.
 - Used by parts of Darwin build process to check compiler flags, etc.
 - <rdar://problem/7256886> clang does not emit AT_APPLE_flags

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91661 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-18 02:43:17 +00:00
Nuno Lopes 99860173af reword the help text of fno_assume_sane_operator_new, following Chris suggestion
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91630 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 22:37:33 +00:00
Ted Kremenek 3cead901aa Convert GRExprEngine::VisitCallExpr() to use a worklist instead of recursion to evaluate the arguments of a CallExpr. This simplifies the logic and makes it easier to read. (it also avoids any issues with blowing out the stack if the CallExpr had a ridiculous number of arguments)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91613 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 20:06:29 +00:00
Nuno Lopes 0a8bab019d implement PR3962: diagnose more faulty cases of usage of the restrict qualifier. this also removes a FIXME
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91601 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 11:35:26 +00:00
Chandler Carruth 3d31560343 Include <time.h> in order to use 'time_t'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91597 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 09:27:29 +00:00
Fariborz Jahanian 6dd30fc45a Diagnose duplicate declaration of a property. Fixes
PR5809


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91575 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-17 00:49:09 +00:00
Ted Kremenek c410d4d2bb Completely remove ObjCObjectRegion (tests pass this time).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91572 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 23:53:37 +00:00
Daniel Dunbar 8663b18008 Fix -fdollars-in-identifiers Clang translation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91562 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 20:10:18 +00:00
Douglas Gregor 16006c9013 When value-initializing a class with no user-defined constructors but
with a non-trivial default constructor, zero-initialize the storage
and then call the default constructor. Fixes PR5800.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91548 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 18:50:27 +00:00
Fariborz Jahanian dd69aae285 Diagnose property of reference type as unsupported
instead of crashing for now. 


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91546 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 18:03:30 +00:00
Nuno Lopes fc2844846e implement PR5654: add -fassume-sane-operator-new, which is enabled by default, and adds the malloc attribute to the global function new() and to the overloaded new operators.
feel free to chage the name to this lengthy argument

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91543 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 16:59:22 +00:00
John McCall 3b4294e5c1 Shift things around so that it's easier to recover from a missing
function in a C++ call using an arbitrary call-expression type.
Actually exploit this to fix the recovery implemented earlier.

The diagnostic is still iffy, though.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91538 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 12:17:52 +00:00
Zhongxing Xu bb14121787 Add a new kind of region: CXXObjectRegion. Currently it has only one
attribute: the object type. 
Add initial support for visiting CXXThisExpr.
Fix a bunch of 80-col violations.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91535 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 11:27:52 +00:00
John McCall 578b69b186 Introduce a centralized routine in Sema for diagnosing failed lookups (when
used as expressions).  In dependent contexts, try to recover by doing a lookup
in previously-dependent base classes.  We get better diagnostics out, but    
unfortunately the recovery fails:  we need to turn it into a method call  
expression, not a bare call expression.  Thus this is still a WIP.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91525 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 08:11:27 +00:00
Zhongxing Xu 3eda63a2e9 remove dead code.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91517 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 06:39:03 +00:00
Eli Friedman 772494c3b8 Add abort() as a builtin. This has two effects: one, we warn for incorrect
declarations of abort(), and two, we mark it noreturn.  Missing the latter
shows up in one of the "embarassing" tests (from the thread on llvmdev
"detailed comparison of generated code size for LLVM and other compilers").



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91515 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 06:28:21 +00:00
Anders Carlsson ac7db1fecf More FullExpr work.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91514 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 06:21:35 +00:00
Anders Carlsson d4a0552ea5 More work on the FullExpr class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91513 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 06:10:22 +00:00
Ted Kremenek 6b8ee78873 Teach CheckerVisitor about CXXOperatorCallExpr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91509 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 05:52:19 +00:00
Ted Kremenek 1c8008715b Teach CFRecStmtDeclVisitor about CXXMethodDecl.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91508 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 05:50:26 +00:00
Douglas Gregor 3ad359b845 Make GRSubEngine.h standalone
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91504 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 03:49:50 +00:00
Douglas Gregor 6864748fc9 Fix semantic diagnostics that embed English works, from Nicola Gigante!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91503 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 03:45:30 +00:00
Ted Kremenek 852274d425 Add (initial?) static analyzer support for handling C++ references.
This change was a lot bigger than I originally anticipated; among
other things it requires us storing more information in the CFG to
record what block-level expressions need to be evaluated as lvalues.

The big change is that CFGBlocks no longer contain Stmt*'s by
CFGElements.  Currently CFGElements just wrap Stmt*, but they also
store a bit indicating whether the block-level expression should be
evalauted as an lvalue.  DeclStmts involving the initialization of a
reference require us treating the initialization expression as an
lvalue, even though that information isn't recorded in the AST.
Conceptually this change isn't that complicated, but it required
bubbling up the data through the CFGBuilder, to GRCoreEngine, and
eventually to GRExprEngine.

The addition of CFGElement is also useful for when we want to handle
more control-flow constructs or other data we want to keep in the CFG
that isn't represented well with just a block of statements.

In GRExprEngine, this patch introduces logic for evaluating the
lvalues of references, which currently retrieves the internal "pointer
value" that the reference represents.  EvalLoad does a two stage load
to catch null dereferences involving an invalid reference (although
this could possibly be caught earlier during the initialization of a
reference).

Symbols are currently symbolicated using the reference type, instead
of a pointer type, and special handling is required creating
ElementRegions that layer on SymbolicRegions (see the changes to
RegionStoreManager).

Along the way, the DeadStoresChecker also silences warnings involving
dead stores to references.  This was the original change I introduced
(which I wrote test cases for) that I realized caused GRExprEngine to
crash.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91501 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 03:18:58 +00:00
Anders Carlsson 5ee56e95c3 Check in a rudimentary FullExpr class that isn't used anywhere yet. Rename Action::FullExpr to Action::MakeFullExpr to avoid name clashes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@91494 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-16 02:09:40 +00:00