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

871 Коммитов

Автор SHA1 Сообщение Дата
Douglas Gregor 9a6da69306 Introduce a cc1-level option to provide the path to the module cache,
where the compiler will look for module files. Eliminates the
egregious hack where we looked into the header search paths for
modules.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139538 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-12 20:41:59 +00:00
Argyrios Kyrtzidis 8f7c540ac4 [libclang] Fix annotation and getting a "macro expansion" cursor
for a builtin macro expansion.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139298 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 17:18:41 +00:00
Douglas Gregor 5471bc85b6 Allow C++0x enumerations with a fixed underlying type in
Objective-C. The @encode'ing of such an enumeration type is the same
as its underlying type. <rdar://problem/5276348>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139297 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 17:18:35 +00:00
Douglas Gregor e97179c675 Implement the Objective-C 'instancetype' type, which is an alias of
'id' that can be used (only!) via a contextual keyword as the result
type of an Objective-C message send. 'instancetype' then gives the
method a related result type, which we have already been inferring for
a variety of methods (new, alloc, init, self, retain). Addresses
<rdar://problem/9267640>.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-08 01:46:34 +00:00
Douglas Gregor b8db7cd9ac Optimize the preprocessor's handling of the __import_module__
keyword. We now handle this keyword in HandleIdentifier, making a note
for ourselves when we've seen the __import_module__ keyword so that
the next lexed token can trigger a module import (if needed). This
greatly simplifies Preprocessor::Lex(), and completely erases the 5.5%
-Eonly slowdown Argiris noted when I originally implemented
__import_module__. Big thanks to Argiris for noting that horrible
regression!



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139265 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-07 23:11:54 +00:00
Richard Smith 7640c00703 Advertise support for cxx_range_for as an extension in C++98 mode. Patch by Jean-Daniel Dupas!
Also provide a modicum of test coverage for ranged for in C++98.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139149 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 18:03:41 +00:00
Benjamin Kramer 1daa58ea89 Speed up BCPL comment lexing by looking aggressively for newlines and then scannig backwards to see if the newline is escaped.
3% speedup in preprocessing all of clang with -Eonly. Also includes a small testcase for coverage.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139116 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-05 07:19:39 +00:00
Benjamin Kramer 5d6ae288bc Use the Lexer's definition of whitespace here.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139115 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-05 07:19:35 +00:00
Benjamin Kramer 41a50a9b73 Use const_cast to avoid warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139104 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 20:26:28 +00:00
Sebastian Redl 74e611a5fd Add test case for defaulted copy and move structure validation.
Fix bug this uncovered.
Address minor comments from Doug.
Enable cxx_implicit_moves feature.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139101 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 18:14:28 +00:00
Argyrios Kyrtzidis 8e85e85b8c Handle a code-completion token being passed to the macro stringify operator.
Fixes http://llvm.org/PR10826.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139087 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 03:32:19 +00:00
Argyrios Kyrtzidis 7d10087234 Support code-completion for C++ inline methods and ObjC buffering methods.
Previously we would cut off the source file buffer at the code-completion
point; this impeded code-completion inside C++ inline methods and,
recently, with buffering ObjC methods.

Have the code-completion inserted into the source buffer so that it can
be buffered along with a method body. When we actually hit the code-completion
point the cut-off lexing or parsing.

Fixes rdar://10056932&8319466

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139086 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 03:32:15 +00:00
Argyrios Kyrtzidis c8c97a03eb Fix Lexer::ComputePreamble when MaxLines parameter is non-zero.
The function was only counting lines that included tokens and not empty lines,
but MaxLines (mainly initiated to the line where the code-completion point resides)
is a count of overall lines (even empty ones).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@139085 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 03:32:04 +00:00
Douglas Gregor 998b3d3e85 Allow the preprocessor to be constructed without performing target-
and language-specific initialization. Use this to allow ASTUnit to
create a preprocessor object *before* loading the AST file. No actual
functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138983 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 23:39:15 +00:00
Argyrios Kyrtzidis e2ca828119 Don't try keeping a 'LeadingEmptyMacroLoc' in NullStmt. This fails
in the face of buffering C++/ObjC method bodies.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138972 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:53:45 +00:00
Douglas Gregor 3e3cd93b2f Teach ASTContext and Preprocessor to hold on to references to the same
LangOptions, rather than making distinct copies of
LangOptions. Granted, LangOptions doesn't actually get modified, but
this will eventually make it easier to construct ASTContext and
Preprocessor before we know all of the LangOptions.




git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138959 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 20:23:19 +00:00
Douglas Gregor 7143aab97c Modules hide macro definitions by default, so that silly things like
include guards don't show up as macro definitions in every translation
unit that imports a module. Macro definitions can, however, be
exported with the intentionally-ugly #__export_macro__
directive. Implement this feature by not even bothering to serialize
non-exported macros to a module, because clients of that module need
not (should not) know that these macros even exist.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138943 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 17:04:32 +00:00
Eli Friedman c0846d623b Make sure to initialize field. Hopefully this will fix some test failures on Windows.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138880 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-31 18:45:31 +00:00
Douglas Gregor 65030af652 Switch __import__ over to __import_module__, so we don't conflict with
existing practice with Python extension modules. Not that Python
extension modules should be using a double-underscored identifier
anyway, but...


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138870 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-31 18:19:09 +00:00
Eli Friedman f84139a133 Change err_pp_file_not_found back to an Error; when it's a Warning, we suppress it in system headers. And it is not a good idea to suppress it in system headers. (This was originally changed in r134996 to implement -MG.)
Fixes <rdar://10041960>.  And also brings down the number of warnings without a flag by one :)



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138842 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 23:07:51 +00:00
Douglas Gregor 1155c42e7b Allow C99 hexfloats in C++0x mode. This change resolves the standards
collision between C99 hexfloats and C++0x user-defined literals by
giving C99 hexfloats precedence. Also, warning about user-defined
literals that conflict with hexfloats and those that have names that
are reserved by the implementation. Fixes <rdar://problem/9940194>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138839 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-30 22:40:35 +00:00
Douglas Gregor ece3894a9f Add and document __has_feature values for the remaining C++0x
features, so clients can check for the availability of these features
even before we get around to implementing them.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138741 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 17:28:38 +00:00
Douglas Gregor 6be16fe900 Take an entirely different approach to handling the "parsing" of
__import__ within the preprocessor, since the prior one foolishly
assumed that Preprocessor::Lex() was re-entrant. We now handle
__import__ at the top level (only), after macro expansion. This should
fix the buildbot failures.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138704 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 06:37:51 +00:00
Douglas Gregor 6aa52ec6b9 Introduce support for a simple module import declaration, which
loads the named module. The syntax itself is intentionally hideous and
will be replaced at some later point with something more
palatable. For now, we're focusing on the semantics:
  - Module imports are handled first by the preprocessor (to get macro
  definitions) and then the same tokens are also handled by the parser
  (to get declarations). If both happen (as in normal compilation),
  the second one is redundant, because we currently have no way to
  hide macros or declarations when loading a module. Chris gets credit
  for this mad-but-workable scheme.
  - The Preprocessor now holds on to a reference to a module loader,
  which is responsible for loading named modules. CompilerInstance is
  the only important module loader: it now knows how to create and
  wire up an AST reader on demand to actually perform the module load.
  - We search for modules in the include path, using the module name
  with the suffix ".pcm" (precompiled module) for the file name. This
  is a temporary hack; we hope to improve the situation in the
  future.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138679 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-26 23:56:07 +00:00
Argyrios Kyrtzidis 03c107a42f Make Lexer::ComputePreamble accept a LangOptions parameter, otherwise it may be
out-of-sync how a file is compiled. Patch by Matthias Kleine!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138580 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 20:39:19 +00:00
Argyrios Kyrtzidis c4b5582908 Silence 'may be used uninitialized' warnings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138475 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 20:33:05 +00:00
Argyrios Kyrtzidis b6c465e17e Amend r138129 (reduction of SLocEntries) which introduced performance regression due
to increased calls to SourceManager::getFileID. (rdar://9992664)

Use a slightly different approach that is more efficient both in terms of speed
(no extra getFileID calls) and in SLocEntries reduction.

Comparing pre-r138129 and this patch we get:

For compiling SemaExpr.cpp reduction of SLocEntries by 26%.
For the boost enum library:
  -SLocEntries -34% (note that this was -5% for r138129)
  -Memory consumption -50%
  -PCH size -31%

Reduced SLocEntries also benefit the hot function SourceManager::getFileID,
evident by the reduced "FileID scans".

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138380 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 21:02:41 +00:00
Argyrios Kyrtzidis 499ea5550d Introduce SourceManager::isInSLocAddrSpace and use it in TokenLexer instead of isInFileID
since it is a bit more efficient.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138379 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 21:02:38 +00:00
Argyrios Kyrtzidis 5d579e7b04 Rename SourceManager::isBeforeInSourceLocationOffset -> isBeforeInSLocAddrSpace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138378 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 21:02:35 +00:00
Argyrios Kyrtzidis c0069d850e TokenLexer::getExpansionLocForMacroDefLoc doesn't need to return an invalid SourceLocation.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138377 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 21:02:32 +00:00
Argyrios Kyrtzidis f8c50652f7 In Lexer::isAtEndOfMacroExpansion use SourceManager::isInFileID and avoid
the extra SourceManager::getFileID call.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138376 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 21:02:30 +00:00
Eli Friedman 70c7b10c64 Don't warn on varaidic macros in C++0x mode.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138257 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 18:48:28 +00:00
Argyrios Kyrtzidis d9d2b679d0 Boost the efficiency of SourceManager::getMacroArgExpandedLocation.
Currently getMacroArgExpandedLocation is very inefficient and for the case
of a location pointing at the main file it will end up checking almost all of
the SLocEntries. Make it faster:

-Use a map of macro argument chunks to their expanded source location. The map
 is for a single source file, it's stored in the file's ContentCache and lazily
 computed, like the source lines cache.
-In SLocEntry's FileInfo add an 'unsigned NumCreatedFIDs' field that keeps track
 of the number of FileIDs (files and macros) that were created during preprocessing
 of that particular file SLocEntry. This is useful when computing the macro argument
 map in skipping included files while scanning for macro arg FileIDs that lexed from
 a specific source file. Due to padding, the new field does not increase the size
 of SLocEntry.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138225 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-21 23:33:04 +00:00
Argyrios Kyrtzidis d60a34a4e5 For assigning SourceLocations to macro arg tokens, reserve a single SLocEntry
for tokens that are lexed consecutively from the same FileID, instead of creating
a SLocEntry for each token. e.g for

   assert(foo == bar);

there will be a single SLocEntry for the "foo == bar" chunk and locations
for the 'foo', '==', 'bar' tokens will point inside that chunk.

For parsing SemaExpr.cpp, this reduced the number of SLocEntries by 25%.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138129 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 22:34:17 +00:00
Argyrios Kyrtzidis ec3b5389a5 Rename TokenLexer::getMacroExpansionLocation -> getExpansionLocForMacroDefLoc, no functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138128 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 22:34:14 +00:00
Craig Topper 0473cd52ea Warn about and truncate UCNs that are too big for their character literal type.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138031 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-19 03:20:12 +00:00
Argyrios Kyrtzidis 5c5f03e402 [libclang] Support code-completion inside macro arguments.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137973 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 19:41:28 +00:00
Argyrios Kyrtzidis 1b2d53647d For the MacroExpands preprocessor callback, also pass the SourceRange
of expansion (for function macros it includes the right paren).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137909 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 01:05:45 +00:00
Argyrios Kyrtzidis 0e870622e4 Make Lexer::GetBeginningOfToken able to handle macro arg expansion locations.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137795 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 00:31:23 +00:00
NAKAMURA Takumi ddddd48da7 De-Unicode-ify.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137430 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 05:49:51 +00:00
Craig Topper 03720fce6e Raw string followup. Pass a couple StringRefs by value.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137301 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 05:10:55 +00:00
Craig Topper 2fa4e86b4f Add support for C++0x raw string literals.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137298 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-11 04:06:15 +00:00
Craig Topper 1661d71756 Fix comment (test commit)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137039 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 06:10:39 +00:00
Sean Hunt e1f6dea1c9 Add a __has_feature macro for generalized initializers, turned off
because we don't support them yet.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@137027 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-07 00:34:32 +00:00
Douglas Gregor b3f8c244a0 Comment the weird behavior of __has_feature(is_empty) and __has_feature(is_pod)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136788 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 17:01:05 +00:00
Eli Friedman 88710f22be A couple fixes for preprocessor expressions:
1. Be more tolerant of comments in -CC (comment-preserving) mode.  We were missing a few cases.

2. Make sure to expand the second FOO in "#if defined FOO FOO".  (See also
r97253, which addressed the case of "#if defined(FOO FOO".)

Fixes PR10286.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136748 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 00:04:13 +00:00
Douglas Gregor 9a14ecbdec Fix a thinko in my __is_empty/__is_pod commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136561 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 07:08:19 +00:00
Douglas Gregor 6887614091 Turn off __has_feature(is_empty) and __has_feature(is_pod) if the
libstdc++ hack has reverted these type traits to keywords. Icky, but
fixes <rdar://problem/9836262>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136560 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 07:01:49 +00:00
Douglas Gregor 2c7b780318 Use the "Bar.h" -> <Foo/Bar.h> remapping for index header maps only as
a fallback, if normal header search fails. Another attempt at
<rdar://problem/9824020>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136557 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 06:28:34 +00:00
Douglas Gregor 65e02fa80e Introduce the "-index-header-map" option, to give special semantics
for quoted header lookup when dealing with not-yet-installed
frameworks. Fixes <rdar://problem/9824020>.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@136331 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 04:45:53 +00:00