Commit Graph

1592 Commits

Author SHA1 Message Date
Justin Bogner 25463f1577 Teach users of OnDiskHashTable to define hash_value and offset types
This paves the way to making OnDiskHashTable work with hashes that are
not 32 bits wide and to making OnDiskHashTable work very large hash
tables. The LLVM change to use these types is upcoming.

llvm-svn: 206640
2014-04-18 20:27:24 +00:00
Justin Bogner bb094f0669 Remove OnDiskHashTable.h, since it's been moved to llvm
llvm-svn: 206637
2014-04-18 19:57:06 +00:00
Dmitri Gribenko 62bcd925c0 Add more constness to module-related APIs
llvm-svn: 206595
2014-04-18 14:36:51 +00:00
Justin Bogner 4e3a01fa5f Lex: Fix __has_feature(cxx_exceptions) for objective C++
At one point, -fexceptions was a synonym for -fcxx-exceptions. While
the driver options still enables cxx-exceptions by default, the cc1
flag is purely about exception tables and this doesn't account for
objective C exceptions. Because of this, checking for the
cxx_exceptions feature in objective C++ often gives the wrong answer.

The cxx_exceptions feature should be based on the -fcxx-exceptions cc1
flag, not -fexceptions. Furthermore, at some point the tests were
changed to use cc1 even though they were testing the driver behaviour.
We're better off testing both the driver and cc1 here.

llvm-svn: 206352
2014-04-16 02:56:48 +00:00
John Thompson 28331ae67e Fixed problem with exclude header. The exclude header argument needs to be relative to the module.map file.
llvm-svn: 206342
2014-04-16 00:07:06 +00:00
Ben Langmuir beee15e721 Allow multiple modules with the same name to coexist in the module cache
To differentiate between two modules with the same name, we will
consider the path the module map file that they are defined by* part of
the ‘key’ for looking up the precompiled module (pcm file).
Specifically, this patch renames the precompiled module (pcm) files from
  cache-path/<module hash>/Foo.pcm
to
  cache-path/<module hash>/Foo-<hash of module map path>.pcm

In addition, I’ve taught the ASTReader to re-resolve the names of
imported modules during module loading so that if the header search
context changes between when a module was originally built and when it
is loaded we can rebuild it if necessary.  For example, if module A
imports module B

first time:
clang -I /path/to/A -I /path/to/B ...

second time:
clang -I /path/to/A -I /different/path/to/B ...

will now rebuild A as expected.

* in the case of inferred modules, we use the module map file that
allowed the inference, not the __inferred_module.map file, since the
inferred file path is the same for every inferred module.

llvm-svn: 206201
2014-04-14 18:00:01 +00:00
Yunzhong Gao ef309f4326 Add a test to distinguish between reserved tokens and normal identifiers.
The -fms-extensions option affects a number of subtle front-end C/C++
behaviors, and it would be useful to be able to distinguish MS keywords
from regular identifiers in the ms-extensions mode even if the triple
does not define a Windows target. It should make life easier if anyone
needs to port their Windows codes to elsewhere.

Differential Revision: http://reviews.llvm.org/D3034

llvm-svn: 206069
2014-04-11 20:55:19 +00:00
Daniel Jasper 962b38e4f3 Add -fmodules-strict-decluse to check that all headers are in modules
Review: http://reviews.llvm.org/D3335
llvm-svn: 206027
2014-04-11 11:47:45 +00:00
Ben Langmuir 4469138e98 Move search for header in umbrella directories into its own function
No functional change intended.

llvm-svn: 205942
2014-04-10 00:39:10 +00:00
Argyrios Kyrtzidis 9ef53ceb51 [Preprocessor/CodeComplete] Don't add include guard macros to code-completion results.
llvm-svn: 205917
2014-04-09 18:21:23 +00:00
Richard Smith 50996ce1e3 If a header is explicitly included in module A, and excluded from an umbrella
directory in module B, don't include it in module B!

llvm-svn: 205762
2014-04-08 13:13:04 +00:00
Roman Divacky 6150990d59 Revert r205436:
Extend the SSE2 comment lexing to AVX2. Only 16byte align when not on AVX2.

        This provides some 3% speedup when preprocessing gcc.c as a single file.


The patch is wrong, it always uses SSE2, and when I fix that there's no speedup
at all. I am not sure where the 3% came from previously.

--Thi lie, and those below, will be ignored--

M    Lex/Lexer.cpp

llvm-svn: 205548
2014-04-03 18:04:52 +00:00
Roman Divacky 071e830bbb Extend the SSE2 comment lexing to AVX2. Only 16byte align when not on AVX2.
This provides some 3% speedup when preprocessing gcc.c as a single file.

llvm-svn: 205436
2014-04-02 17:27:03 +00:00
Aaron Ballman 759c71d621 Post-commit review coding style change: renaming HasAttribute to hasAttribute. No functional changes.
llvm-svn: 205201
2014-03-31 15:26:40 +00:00
Aaron Ballman 2fbf99429a Reapplying r204952 a second time.
Clean up the __has_attribute implementation without modifying its behavior. 

Replaces the tablegen-driven AttrSpellings.inc, which lived in the lexing layer with AttrHasAttributeImpl.inc, which lives in the basic layer. Updates the preprocessor to call through to this new functionality which can take additional information into account (such as scopes and syntaxes).

Expose the ability for parts of the compiler to ask whether an attribute is supported for a given spelling (including scope), syntax, triple and language options.

llvm-svn: 205181
2014-03-31 13:14:44 +00:00
Argyrios Kyrtzidis 7bd78a910a [HeaderSearch] Make sure we clear the mapped name from the LookupFileCacheInfo when we reset the start point.
rdar://16462455

llvm-svn: 205071
2014-03-29 03:22:54 +00:00
Justin Bogner 57ba0b228d Reapply "OnDiskHashTable: Use Endian.h to read little endian ostreams"
Committed this by accident before it was done last time.

Original message:

    Rather than rolling our own functions to read little endian data
    from a buffer, we can use the support in llvm's Endian.h.

    No functional change.

llvm-svn: 205062
2014-03-28 22:03:24 +00:00
Justin Bogner e1c147c3cf Reapply "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"
Committed this by accident before it was done last time.

Original message:

    Rather than rolling our own functions to write little endian data
    to an ostream, we can use the support in llvm's EndianStream.h.

    No functional change.

llvm-svn: 205061
2014-03-28 22:03:19 +00:00
Justin Bogner a0dafb77eb Revert "OnDiskHashTable: Use Endian.h to read little endian ostreams"
This reverts commit r205045.

llvm-svn: 205048
2014-03-28 20:32:17 +00:00
Justin Bogner d42773bcc8 Revert "OnDiskHashTable: Use EndianStream.h to write little endian ostreams"
This reverts commit r205044.

llvm-svn: 205047
2014-03-28 20:32:11 +00:00
Justin Bogner 498d82ee3e OnDiskHashTable: Use Endian.h to read little endian ostreams
Rather than rolling our own functions to read little endian data from
a buffer, we can use the support in llvm's Endian.h.

No functional change.

llvm-svn: 205045
2014-03-28 20:04:01 +00:00
Justin Bogner a06321efdd OnDiskHashTable: Use EndianStream.h to write little endian ostreams
Rather than rolling our own functions to write little endian data to
an ostream, we can use the support in llvm's EndianStream.h.

No functional change.

llvm-svn: 205044
2014-03-28 20:03:54 +00:00
Aaron Ballman 0efd167f81 Reverting r204968 and r204969; while more build bots are happy with the results, some still have link errors.
llvm-svn: 204974
2014-03-27 22:37:56 +00:00
Aaron Ballman c9ad1ca715 Reapplying r204952 with fixes which should hopefully resolve linking issues with non-MSVC compilers.
llvm-svn: 204968
2014-03-27 22:12:09 +00:00
Aaron Ballman 0702d02b31 Reverting r204952, while I figure out what's going on with the makefile build.
llvm-svn: 204955
2014-03-27 20:36:32 +00:00
Aaron Ballman 9cac6f5f04 Clean up the __has_attribute implementation without modifying its behavior.
Replaces the tablegen-driven AttrSpellings.inc, which lived in the lexing layer with AttrHasAttributeImpl.inc, which lives in the basic layer. Updates the preprocessor to call through to this new functionality which can take additional information into account (such as scopes and syntaxes).

Expose the ability for parts of the compiler to ask whether an attribute is supported for a given spelling (including scope), syntax, triple and language options.

llvm-svn: 204952
2014-03-27 20:19:24 +00:00
Ben Langmuir c3ea5654f9 Prevent lookup of subframework modules by name without parent framework
We were 'allowing' the following import
@import Sub;

where Sub is a subframework of Foo and we had a -F path inside
Foo.framework/Frameworks and no module map file for Sub. This would
later hit assertion failures in debug builds.

Now we should correctly diagnose this as a module not found error.

llvm-svn: 204368
2014-03-20 18:27:26 +00:00
Aaron Ballman d8de5b6868 Silencing an MSVC warning about not all control paths returning a value. No functional change intended.
llvm-svn: 204345
2014-03-20 14:22:33 +00:00
Ben Langmuir 984e1df77a Add a new spelling for module map files 'module.modulemap'
This name, while more verbose, plays more nicely with tools that use
file extensions to determine file types. The existing spelling
'module.map' will continue to work, but the new spelling will take
precedence.

In frameworks, this new filename will only go in a new 'Modules'
sub-directory.

Similarly, add a module.private.modulemap corresponding to
module_private.map.

llvm-svn: 204261
2014-03-19 20:23:34 +00:00
Manuel Klimek 98a9a6c667 Use the expansion location of the file name when finding the module.
The spelling location of stringified strings is not a file location.
Optimally, we'll want to solve the problem (as the FIXME states) by
handing in the right FileEntry of the #include location.

llvm-svn: 204220
2014-03-19 10:22:36 +00:00
Marshall Clow d28acc0d98 Added a __has_feature() for 'is_constructible'
llvm-svn: 204153
2014-03-18 14:13:10 +00:00
Benjamin Kramer 329c596e58 Preprocessor: Clarify the ownership of the IncludeMacroStack with unique_ptr.
llvm-svn: 204007
2014-03-15 16:40:40 +00:00
Richard Smith ae385084c5 Implement the MS extension __identifier properly: take a token and strip it of
its keywordliness.

llvm-svn: 203987
2014-03-15 00:06:08 +00:00
Richard Smith 7e34fbdaa0 Add two missing entries to the C++11 support page. Bump one relevant diagnostic
(for an integer too large for any signed type) from Warning to ExtWarn -- it's
ill-formed in C++11 and C99 onwards, and UB during translation in C89 and
C++98. Add diagnostic groups for two relevant diagnostics.

llvm-svn: 203974
2014-03-14 21:21:24 +00:00
Daniel Jasper 5c77e39f2d Don't verify module inclusions in assembler files.
llvm-svn: 203929
2014-03-14 14:53:17 +00:00
Ben Langmuir d285c50390 Prevent outputting HeaderFileInfos for files not used as headers
When building an AST file, we don't want to output HeaderFileInfo
structures for files that are not actually used as headers in the
current context.  This can lead to assuming that unrelated files have
include counts of 0, defeating multiple-include prevention.

This is accomplished by adding an IsValid bit to the HFI.

llvm-svn: 203813
2014-03-13 16:46:36 +00:00
Richard Smith 5b5d21ea1a Only allow streaming exactly type 'bool' to a DiagnosticBuilder, not anything
that implicitly converts to 'bool' (such as pointers, and the first operand of
?:). Clean up issues found by this. Patch by Stephan Tolksdorf!

llvm-svn: 203735
2014-03-12 23:36:42 +00:00
Saleem Abdulrasool 729b7d357d Lex: reduce buffer size, add a test
Reduce the stack usage as hopefully include paths are usually not too long.  Add
a test case for the path normalisation behaviour.

llvm-svn: 203632
2014-03-12 02:26:08 +00:00
Saleem Abdulrasool 198034105d lex: improve include handling on Linux for Windows
Normalise the path separator character on non-windows platforms.  Although this
would work on Windows as well (most newer versions of Windows support either '/'
or '\' as a path separator character), it could potentially cause problems with
full UNC paths.  This change enables the use of the Windows SDK on Linux which
will not accept '\' as a path separator.

llvm-svn: 203614
2014-03-11 22:41:45 +00:00
Craig Topper 9140dd2fe7 [C++11] Add 'override' keyword to virtual methods that override their base class.
llvm-svn: 203547
2014-03-11 06:50:42 +00:00
Argyrios Kyrtzidis 34fad42003 [HeaderSearch] Fix issue where if a headermap entry maps the filename to a framework import (non-absolute path)
then we fail to find it if it is re-included later on.

rdar://16285490

llvm-svn: 203542
2014-03-11 06:21:28 +00:00
Ahmed Charles dfca6f97bc [C++11] Replace OwningPtr include with <memory>.
llvm-svn: 203389
2014-03-09 11:36:40 +00:00
David Blaikie dcb72d72ff Remove uses of SmallString::equals in favor of SmallVectorImpl<char>'s operator==
llvm-svn: 203373
2014-03-09 05:18:27 +00:00
Argyrios Kyrtzidis 8ed7414e58 [Preprocessor] Only check for -Wunused-macros if the translation unit kind is TU_Complete.
llvm-svn: 203360
2014-03-08 21:18:26 +00:00
Ahmed Charles b89843299a Replace OwningPtr with std::unique_ptr.
This compiles cleanly with lldb/lld/clang-tools-extra/llvm.

llvm-svn: 203279
2014-03-07 20:03:18 +00:00
Ahmed Charles 9a16beb8bc Change OwningPtr::take() to OwningPtr::release().
This is a precursor to moving to std::unique_ptr.

llvm-svn: 203275
2014-03-07 19:33:25 +00:00
Argyrios Kyrtzidis e1974dcd92 [Preprocessor] Pass TranslationUnitKind to the preprocessor and if it is TU_Prefix
avoid warning for unused macros.

rdar://15034698

llvm-svn: 203213
2014-03-07 07:47:58 +00:00
Ben Langmuir cb69b57b2a Add dependencies from imported modules with -MD
Add module dependencies to the dependency files created by -MD/-MMD/etc.
by attaching an ASTReaderListener that will call into the dependency
file generator when a module input file is seen in the serialized AST.

llvm-svn: 203208
2014-03-07 06:40:32 +00:00
Richard Smith 131daca01d Remove a dead store, add a FIXME for another.
llvm-svn: 203169
2014-03-06 21:59:38 +00:00
Richard Smith 6f548ec37e Fix use-after-free detected by ASan bootstrap.
llvm-svn: 203140
2014-03-06 18:08:08 +00:00
Richard Smith 8c71eba19f If a #include finds a file relative to the current file, don't forget to check
whether it's part of a module.

llvm-svn: 203005
2014-03-05 20:51:45 +00:00
Chandler Carruth 06dde92cd6 [C++11] Switch from LLVM_STATIC_ASSERT to static_assert now that we
require host toolchains which support this.

llvm-svn: 202640
2014-03-02 13:02:01 +00:00
Benjamin Kramer 867ea1d426 [C++11] Replace llvm::tie with std::tie.
llvm-svn: 202639
2014-03-02 13:01:17 +00:00
Richard Smith 7794486846 Add [extern_c] attribute for modules, allowing a C module to be imported within an extern "C" block in C++ code.
llvm-svn: 202615
2014-03-02 05:58:18 +00:00
Richard Smith 49f906a36f If a module A exports a macro M, and a module B imports that macro and #undef's
it, importers of B should not see the macro. This is complicated by the fact
that A's macro could also be visible through a different path. The rules (as
hashed out on cfe-commits) are included as a documentation update in this
change.

With this, the number of regressions in libc++'s testsuite when modules are
enabled drops from 47 to 7. Those remaining 7 are also macro-related, and are
due to remaining bugs in this change (in particular, the handling of submodules
is imperfect).

llvm-svn: 202560
2014-03-01 00:08:04 +00:00
Ben Langmuir d066d4c849 Reapply fixed "Honour 'use-external-names' in FileManager"
Was r202442

There were two issues with the original patch that have now been fixed.
1. We were memset'ing over a FileEntry in a test case. After adding a
   std::string to FileEntry, this still happened to not break for me.
2. I didn't pass the FileManager into the new compiler instance in
   compileModule. This was hidden in some cases by the fact I didn't
   clear the module cache in the test.

Also, I changed the copy constructor for FileEntry, which was memcpy'ing
in a (now) unsafe way.

llvm-svn: 202539
2014-02-28 21:16:07 +00:00
Richard Smith 35ddad0723 Fix a minor bug in lexing pp-numbers with digit separators: if a pp-number contains "'e+", the pp-number ends between the 'e' and the '+'.
llvm-svn: 202533
2014-02-28 20:06:02 +00:00
Ben Langmuir 1b8d44f59b Revert "Honour 'use-external-names' in FileManager"
Revert r202442, which broke the buildbots.

llvm-svn: 202443
2014-02-27 23:48:03 +00:00
Ben Langmuir 09e0d5c1bb Honour 'use-external-names' in FileManager
Pass through the externally-visible names that we got from the VFS down
to FileManager, and test that this is the name showing up in __FILE__,
diagnostics, and debug information.

llvm-svn: 202442
2014-02-27 23:27:54 +00:00
NAKAMURA Takumi 9698686505 [CMake] Use LINK_LIBS instead of target_link_libraries().
llvm-svn: 202238
2014-02-26 06:41:29 +00:00
Richard Smith f2baa70396 If the first token in a macro that appears at the start of a line expands to
nothing, be sure to inform the *next* token expanded from the macro that it is
now at the start of a line. Patch by Harald van Dijk!

llvm-svn: 202068
2014-02-24 20:45:00 +00:00
Alp Toker 7d2fea2fd6 Use a more conventional logical op instead of bitwise and
llvm-svn: 202006
2014-02-24 04:35:58 +00:00
NAKAMURA Takumi 7da9487dd4 [CMake] Get rid of explicit dependencies to include/clang/*.inc and introduce CLANG_TABLEGEN_TARGETS.
This does;
  - clang_tablegen() adds each tblgen'd target to global property CLANG_TABLEGEN_TARGETS as list.
  - List of targets is added to LLVM_COMMON_DEPENDS.
  - all clang libraries and targets depend on generated headers.

You might wonder this would be regression, but in fact, this is little loss.
  - Almost all of clang libraries depend on tblgen'd files and clang-tblgen.
  - clang-tblgen may cause short stall-out but doesn't cause unconditional rebuild.
  - Each library's dependencies to tblgen'd files might vary along headers' structure.
    It made hard to track and update *really optimal* dependencies.

Each dependency to intrinsics_gen and ClangSACheckers is left as DEPENDS.

llvm-svn: 201842
2014-02-21 07:59:59 +00:00
Ben Langmuir c8130a74f4 Recommit virtual file system
Previously reverted in r201755 due to causing an assertion failure.

I've removed the offending assertion, and taught the CompilerInstance to
create a default virtual file system inside createFileManager. In the
future, we should be able to reach into the CompilerInvocation to
customize this behaviour without breaking clients that don't care.

llvm-svn: 201818
2014-02-20 21:59:23 +00:00
Juergen Ributzka a32575e4f6 Reverting the virtual file system implementation, because it triggers an assertion
in our internal build bots.

This reverts commits 201618, 201635, 201636, 201639, 201685, 201691, and 201696.

llvm-svn: 201755
2014-02-20 05:24:58 +00:00
Reid Kleckner 588c937228 Use llvm::DeleteContainerSeconds when possible
llvm-svn: 201739
2014-02-19 23:44:52 +00:00
Ben Langmuir 090610d37a Initial implementation of virtual file system
This adds the minimum virtual file system support to start migrating
FileManager onto the VFS.

Originally discussed here:
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-February/035188.html

Differential Revision: http://llvm-reviews.chandlerc.com/D2745

llvm-svn: 201618
2014-02-19 00:10:30 +00:00
Reid Kleckner a97d4c0679 Fix false positives in -Wmsvc-include by continuing header search
This makes Clang and LLVM -Wmsvc-include clean.

I believe the correct behavior here is to avoid updating the cache when
we find the header via MSVC's search rules.

Differential Revision: http://llvm-reviews.chandlerc.com/D2733

llvm-svn: 201615
2014-02-18 23:49:24 +00:00
Richard Smith 7b1573451e Fix a non-error diagnostic that had an err_ name. Also move it from Warning to
ExtWarn, since it's an extension.

llvm-svn: 201540
2014-02-18 00:45:50 +00:00
Richard Smith 8b7258bdb3 PR18855: Add support for UCNs and UTF-8 encoding within ud-suffixes.
llvm-svn: 201532
2014-02-17 21:52:30 +00:00
Argyrios Kyrtzidis 75fa9eddae If the headermap maps the filename to a framework include ("Foo.h" -> "Foo/Foo.h"),
continue header lookup using the framework include as filename.

This allows us to conveniently treat
  #import "Foo.h"
as an implicit module import if we can resolve "Foo/Foo.h" as such.

rdar://16042979

llvm-svn: 201419
2014-02-14 14:58:28 +00:00
Reid Kleckner c0dca6ded7 MS ABI: Implement #pragma vtordisp() and clang-cl /vdN
These features are new in VS 2013 and are necessary in order to layout
std::ostream correctly.  Currently we have an ABI incompatibility when
self-hosting with the 2013 stdlib in our convertible_fwd_ostream wrapper
in gtest.

This change adds another implicit attribute, MSVtorDispAttr, because
implicit attributes are currently the best way to make sure the
information stays on class templates through instantiation.

Reviewers: majnemer

Differential Revision: http://llvm-reviews.chandlerc.com/D2746

llvm-svn: 201274
2014-02-12 23:50:26 +00:00
Joey Gouly 18730ba4ab Fix the range for Malayam UCNs in C99.
llvm-svn: 200845
2014-02-05 15:32:23 +00:00
Justin Bogner d554a8eb91 Clean up whitespace checks
In TokenLexer::ExpandFunctionArguments(), CurTok.hasLeadingSpace() is
checked in multiple locations, each time subtly differently. Checking it
early, when the token is seen, and using NextTokGetsSpace exclusively
after that makes the code simpler.

No change in behaviour is intended.

Patch by Harald van Dijk!

llvm-svn: 200788
2014-02-04 19:18:37 +00:00
Justin Bogner 79c93845f6 Fix whitespace handling in empty macro expansions
When a macro expansion does not result in any tokens, and the macro name
is preceded by whitespace, the whitespace should be passed to the first
token that follows the macro expansion. Similarly when a macro expansion
ends with a placemarker token, and that placemarker token is preceded by
whitespace. This worked already for top-level macro expansions, but is
now extended to also work for nested macro expansions.

Patch by Harald van Dijk!

llvm-svn: 200787
2014-02-04 19:18:35 +00:00
Justin Bogner eacd96d972 Fix whitespace handling in empty macro arguments
When a function-like macro definition ends with one of the macro's
parameters, and the argument is empty, any whitespace before the
parameter name in the macro definition needs to be preserved. Promoting
the existing NextTokGetsSpace to a preserved bit-field and checking it
at the end of the macro expansion allows it to be moved to the first
token following the macro expansion result.

Patch by Harald van Dijk!

llvm-svn: 200786
2014-02-04 19:18:32 +00:00
Justin Bogner 502155aff9 Fix whitespace handling in ## operator
In x ## y, where x and y are regular tokens, whitespace between x and ##
is ignored, and whitespace between ## and y is also ignored. When either
x or y is a function argument, whitespace was preserved, but it should
not be. This patch removes the checks for whitespace before ## and
before y, and in the special case where x is an empty macro argument and
y is a regular token, actively removes whitespace before y.

One existing test is affected by that change, but as clang's output now
matches the standard's requirements and that of GCC, I've tweaked the
testcase.

Patch by Harald van Dijk!

llvm-svn: 200785
2014-02-04 19:18:28 +00:00
Richard Smith 67294e253e Track the currently-being-built submodule inside the preprocessor (rather than
just storing a flag indicating if there was one), and include it in the 'end of
module' annotation. No functionality change.

llvm-svn: 200573
2014-01-31 20:47:44 +00:00
Ben Langmuir 5eb7cb74a7 Revert "Fix assertion failures on annot_* tokens in clang -E"
This is causing a failure in the msan buildbot that I am having trouble
reproducing.  Reverting until I can figure out what went wrong.

llvm-svn: 200492
2014-01-30 21:50:18 +00:00
Ben Langmuir 5944ecd64c Fix assertion failures on annot_* tokens in clang -E
In particular, #pragma clang __debug, and #include implicitly changed
into @import were causing assertion failures.

llvm-svn: 200475
2014-01-30 18:09:55 +00:00
Richard Smith 2e87e14490 Remove dead code; MacroDirective's IsHidden flag is always false.
llvm-svn: 200265
2014-01-27 23:54:39 +00:00
Alp Toker 29cb66ba2f Enforce safe usage of DiagnosticsEngine::getCustomDiagID()
Replace the last incorrect uses and templatize the function to require a
compile-time constant string preventing further misuse.

The diagnostic formatter expects well-formed input and has undefined behaviour
with arbitrary input or crafted user strings in source files. Accepting user
input would also have caused unbounded generation of new diagnostic IDs which
can be problematic in long-running sessions or language bindings.

This completes the work to fix several incorrect callers that passed user
input or raw messages to the diagnostics engine where a constant format string
was expected.

llvm-svn: 200132
2014-01-26 06:17:37 +00:00
Alp Toker a8bb9c97c6 Fix cxx_variable_templates feature check and documentation
This C++ feature has been marked complete since r191549, but the documentation
claimed it wasn't supported at all and the extension check misreported it as
being available in C.

No regression test; this was a short-lived typo.

llvm-svn: 199292
2014-01-15 04:11:24 +00:00
Alp Toker bfa3934f27 Rename language option MicrosoftMode to MSVCCompat
There's been long-standing confusion over the role of these two options. This
commit makes the necessary changes to differentiate them clearly, following up
from r198936.

MicrosoftExt (aka. fms-extensions):
 Enable largely unobjectionable Microsoft language extensions to ease
 portability. This mode, also supported by gcc, is used for building software
 like FreeBSD and Linux kernel extensions that share code with Windows drivers.

MSVCCompat (aka. -fms-compatibility, formerly MicrosoftMode):
 Turn on a special mode supporting 'heinous' extensions for drop-in
 compatibility with the Microsoft Visual C++ product. Standards-compilant C and
 C++ code isn't guaranteed to work in this mode. Implies MicrosoftExt.

Note that full -fms-compatibility mode is currently enabled by default on the
Windows target, which may need tuning to serve as a reasonable default.

See cfe-commits for the full discourse, thread 'r198497 - Move MS predefined
type_info out of InitializePredefinedMacros'

No change in behaviour.

llvm-svn: 199209
2014-01-14 12:51:41 +00:00
Aaron Ballman 0fa06d879a __has_attribute now understands target-specific attributes. So when you ask whether an ARM target has the "interrupt" attribute, it will return true for ARM and MSP430 targets, and false for others.
llvm-svn: 198897
2014-01-09 22:57:44 +00:00
Chandler Carruth 5553d0d4ca Sort all the #include lines with LLVM's utils/sort_includes.py which
encodes the canonical rules for LLVM's style. I noticed this had drifted
quite a bit when cleaning up LLVM, so wanted to clean up Clang as well.

llvm-svn: 198686
2014-01-07 11:51:46 +00:00
Alp Toker 35d8703dbe Switch over more of the parser to err_expected
Includes a fix for a missing highlight range caused by a ',' typo in the PP
diagnostics.

llvm-svn: 198252
2013-12-30 23:29:50 +00:00
Alp Toker 751d635a2a Cleanup: Switch the preprocessor to err_pp_expected_after
This is approaching consistency but the PP and Parse categories they still have
slightly different wording:

def err_pp_expected_after : Error<"missing %1 after %0">;
def err_expected_after   : Error<"expected %1 after %0">;

llvm-svn: 198189
2013-12-30 01:59:29 +00:00
Will Wilson ba2f146c87 Silence compile warning by removing unused SourceMgr member
llvm-svn: 198083
2013-12-27 20:02:27 +00:00
Will Wilson 0fafd34a6e Implement MSVC header search algorithm in MicrosoftMode.
Follows algorithm described here: http://msdn.microsoft.com/en-us/library/36k2cdd4.aspx

llvm-svn: 198082
2013-12-27 19:46:16 +00:00
Alp Toker ec543279db Support and use token kinds as diagnostic arguments
Introduce proper facilities to render token spellings using the diagnostic
formatter.

Replaces most of the hard-coded diagnostic messages related to expected tokens,
which all shared the same semantics but had to be multiply defined due to
variations in token order or quote marks.

The associated parser changes are largely mechanical but they expose
commonality in whole chunks of the parser that can now be factored away.

This commit uses C++11 typed enums along with a speculative legacy fallback
until the transition is complete.

Requires corresponding changes in LLVM r197895.

llvm-svn: 197972
2013-12-24 09:48:30 +00:00
Richard Trieu 0732beb21f Use this one little trick to prevent optimizers from removing an
intentional stack overflow.

llvm-svn: 197849
2013-12-21 01:04:02 +00:00
Daniel Jasper 92669ee45c Enable layering check in unavailable modules.
If a header file belonging to a certain module is not found on the
filesystem, that header gets marked as unavailable. Now, the layering
warning (-fmodules-decluse) should still warn about headers of this
module being wrongfully included. Currently, headers belonging to those
modules are just treated as not belonging to modules at all which means
they can be included freely from everywhere.

To implement this (somewhat) cleanly, I have moved most of the layering
checks into the ModuleMap. This will also help with showing FixIts
later.

llvm-svn: 197805
2013-12-20 12:09:36 +00:00
Will Wilson 9ef61a7ca7 Fix comment typo.
llvm-svn: 197695
2013-12-19 16:24:17 +00:00
Daniel Jasper 0761a8a085 Modules: Don't warn upon missing headers while reading the module map.
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.

This works towards the long-term goal of not stat'ing the header files at all
while reading the module map and instead read them only when the module is
being built (there is a corresponding FIXME in parseHeaderDecl()).  However, it
seems non-trivial to get there and this unblock us and moves us into the right
direction.

Also changed the implementation to reuse the same DiagnosticsEngine.

llvm-svn: 197485
2013-12-17 10:31:37 +00:00
Daniel Jasper 34dc4811a2 Revert "Modules: Make missing headers in a module.map a warning not an error."
This was committed accidentally.

llvm-svn: 197389
2013-12-16 14:57:22 +00:00
Daniel Jasper 5c6ee49fa0 Modules: Make missing headers in a module.map a warning not an error.
Instead, mark the module as unavailable so that clang errors as soon as
someone tries to build this module.

A better long-term strategy might be to not stat the header files at all
while reading the module map and instead read them only when the module
is being built (there is a corresponding FIXME in parseHeaderDecl()).
However, it seems non-trivial to get there and this would be a temporary
solution to unblock us.

Also changed the implementation to reuse the same DiagnosticsEngine as
otherwise warnings can't be enabled or disabled with command-line flags.

llvm-svn: 197388
2013-12-16 14:53:57 +00:00
Alp Toker 6de6da603e Lexer: Issue -Wbackslash-newline-escape for line comments
The warning for backslash and newline separated by whitespace was missed in
this code path.

backslash<whitespace><newline> is handled differently from compiler to compiler
so it's important to warn consistently where there's ambiguity.

Matches similar handling of block comments and non-comment lines.

llvm-svn: 197331
2013-12-14 23:32:31 +00:00
Alp Toker 08c2500f9c Fix raw lex crash and -frewrite-includes noeol-at-eof failure
Raw lexers don't have a preprocessor so we need to null check.

llvm-svn: 197245
2013-12-13 17:04:55 +00:00
Argyrios Kyrtzidis 9955dbca2f [Modules] Don't parse any module map if modules are disabled.
Fixes rdar://15644663.

llvm-svn: 197165
2013-12-12 16:08:33 +00:00