llvm-project/clang/lib/Sema
Dimitry Andric c7bc461298 Don't trigger -Wuser-defined-literals for system headers
Summary:
In D41064, I proposed adding `#pragma clang diagnostic ignored
"-Wuser-defined-literals"` to some of libc++'s headers, since these
warnings are now triggered by clang's new `-std=gnu++14` default:

```
$ cat test.cpp
#include <string>

$ clang -std=c++14 -Wsystem-headers -Wall -Wextra -c test.cpp
In file included from test.cpp:1:
In file included from /usr/include/c++/v1/string:470:
/usr/include/c++/v1/string_view:763:29: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char> operator "" sv(const char *__str, size_t __len)
                            ^
/usr/include/c++/v1/string_view:769:32: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<wchar_t> operator "" sv(const wchar_t *__str, size_t __len)
                               ^
/usr/include/c++/v1/string_view:775:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char16_t> operator "" sv(const char16_t *__str, size_t __len)
                                ^
/usr/include/c++/v1/string_view:781:33: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string_view<char32_t> operator "" sv(const char32_t *__str, size_t __len)
                                ^
In file included from test.cpp:1:
/usr/include/c++/v1/string:4012:24: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char> operator "" s( const char *__str, size_t __len )
                       ^
/usr/include/c++/v1/string:4018:27: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<wchar_t> operator "" s( const wchar_t *__str, size_t __len )
                          ^
/usr/include/c++/v1/string:4024:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char16_t> operator "" s( const char16_t *__str, size_t __len )
                           ^
/usr/include/c++/v1/string:4030:28: warning: user-defined literal suffixes not starting with '_' are reserved [-Wuser-defined-literals]
    basic_string<char32_t> operator "" s( const char32_t *__str, size_t __len )
                           ^
8 warnings generated.
```

Both @aaron.ballman and @mclow.lists felt that adding this workaround to
the libc++ headers was the wrong way, and it should be fixed in clang
instead.

Here is a proposal to do just that.  I verified that this suppresses the
warning, even when -Wsystem-headers is used, and that the warning is
still emitted for a declaration outside of system headers.

Reviewers: aaron.ballman, mclow.lists, rsmith

Reviewed By: aaron.ballman

Subscribers: mclow.lists, aaron.ballman, andrew, emaste, cfe-commits

Differential Revision: https://reviews.llvm.org/D41080

llvm-svn: 320755
2017-12-14 22:32:24 +00:00
..
AnalysisBasedWarnings.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
AttributeList.cpp Add -f[no-]double-square-bracket-attributes as new driver options to control use of [[]] attributes in all language modes. This is the initial implementation of WG14 N2165, which is a proposal to add [[]] attributes to C2x, but also allows you to enable these attributes in C++98, or disable them in C++11 or later. 2017-10-15 15:01:42 +00:00
CMakeLists.txt Enabling the /bigobj flag for SemaDeclAttr.cpp. 2017-05-12 14:30:49 +00:00
CodeCompleteConsumer.cpp [clang] Expose orderedString from CodeCompletionResult. NFC 2017-11-15 09:15:06 +00:00
CoroutineStmtBuilder.h [coroutines] Fix rebuilding of dependent coroutine parameters 2017-06-03 00:22:18 +00:00
DeclSpec.cpp Remove old concepts parsing code 2017-12-07 00:34:20 +00:00
DelayedDiagnostic.cpp [Sema] Don't allow -Wunguarded-availability to be silenced with redecls 2017-07-05 17:08:56 +00:00
IdentifierResolver.cpp
JumpDiagnostics.cpp [Sema][ObjC] Disallow jumping into ObjC fast enumeration loops. 2017-04-19 17:54:08 +00:00
MultiplexExternalSemaSource.cpp Fix warnings. [-Wdocumentation] 2017-10-12 09:42:14 +00:00
Scope.cpp [Parser] Clear the TemplateParamScope bit of the current scope's flag 2016-04-29 02:24:14 +00:00
ScopeInfo.cpp [coroutines] Fix diagnostics depending on the first coroutine statement. 2017-03-11 02:35:37 +00:00
Sema.cpp Remove creation of out-of-bounds value of enumeration type (resulting in UB). 2017-12-08 23:29:59 +00:00
SemaAccess.cpp P0136R1, DR1573, DR1645, DR1715, DR1736, DR1903, DR1941, DR1959, DR1991: 2016-06-28 19:03:57 +00:00
SemaAttr.cpp -Wpragma-pack: add an additional note and fixit when warning 2017-07-31 13:37:50 +00:00
SemaCUDA.cpp Function with unparsed body is a definition 2017-06-21 12:46:57 +00:00
SemaCXXScopeSpec.cpp Add support for editor placeholders to Clang 2017-04-19 08:58:56 +00:00
SemaCast.cpp Allow the target field of a CK_ToUnion to be more easily recovered. 2017-08-15 21:42:47 +00:00
SemaChecking.cpp [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
SemaCodeComplete.cpp [Sema] Ignore decls in namespaces when global decls are not wanted. 2017-12-13 10:26:49 +00:00
SemaConsumer.cpp
SemaCoroutine.cpp [coroutines] Make sure auto return type of await_resume is properly handled 2017-09-05 19:31:52 +00:00
SemaDecl.cpp PR35586: Relax two asserts that are overly restrictive 2017-12-11 19:44:28 +00:00
SemaDeclAttr.cpp [ThreadSafetyAnalysis] Fix isCapabilityExpr 2017-12-14 22:24:45 +00:00
SemaDeclCXX.cpp Don't trigger -Wuser-defined-literals for system headers 2017-12-14 22:32:24 +00:00
SemaDeclObjC.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaExceptionSpec.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaExpr.cpp [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
SemaExprCXX.cpp Revert a part of 320489 that was submitted unintentionally. 2017-12-12 16:22:31 +00:00
SemaExprMember.cpp Fix -Wunused-private-field to fire regardless of which implicit special members have been implicitly declared. 2017-11-01 04:52:12 +00:00
SemaExprObjC.cpp [ObjC] Boxed strings should use the nullability from stringWithUTF8String's return type 2017-11-08 21:33:15 +00:00
SemaFixItUtils.cpp
SemaInit.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaLambda.cpp [Sema] Fix crash in unused-lambda-capture warning for VLAs 2017-12-11 18:00:36 +00:00
SemaLookup.cpp [modules] Retain multiple using-directives in the same scope even if they name the same namespace. 2017-10-30 22:38:20 +00:00
SemaObjCProperty.cpp [Sema] Add support for flexible array members in Obj-C. 2017-10-23 22:01:41 +00:00
SemaOpenMP.cpp [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
SemaOverload.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaPseudoObject.cpp Replace a use of std::for_each() with llvm::for_each(); NFC. 2017-11-03 20:09:17 +00:00
SemaStmt.cpp [c++20] P0515R3: Parsing support and basic AST construction for operator <=>. 2017-12-14 15:16:18 +00:00
SemaStmtAsm.cpp [X86][MS-InlineAsm] Extended support for variables / identifiers on memory / immediate expressions 2017-09-29 07:02:49 +00:00
SemaStmtAttr.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaTemplate.cpp Remove old concepts parsing code 2017-12-07 00:34:20 +00:00
SemaTemplateDeduction.cpp Now that C++17 is official (https://www.iso.org/standard/68564.html), start changing the C++1z terminology over to C++17. NFC intended, these are all mechanical changes. 2017-12-04 20:27:34 +00:00
SemaTemplateInstantiate.cpp Generalize "static data member instantiated" notification to cover variable templates too. 2017-12-05 01:31:47 +00:00
SemaTemplateInstantiateDecl.cpp Generalize "static data member instantiated" notification to cover variable templates too. 2017-12-05 01:31:47 +00:00
SemaTemplateVariadic.cpp Recommit "Add _Float16 as a C/C++ source language type" 2017-09-08 15:15:00 +00:00
SemaType.cpp When attempting to complete an incomplete array bound type in an expression, 2017-12-14 15:40:16 +00:00
TreeTransform.h Remove unused variables. No functionality change. 2017-10-08 21:23:02 +00:00
TypeLocBuilder.cpp
TypeLocBuilder.h Retire llvm::alignOf in favor of C++11 alignof. 2016-10-20 14:27:22 +00:00