[clang] adding explicit(bool) from c++2a
authorNicolas Lesser <blitzrakete@gmail.com>
Sat, 4 May 2019 00:09:00 +0000 (00:09 +0000)
committerNicolas Lesser <blitzrakete@gmail.com>
Sat, 4 May 2019 00:09:00 +0000 (00:09 +0000)
commit5fe2ddbdf47dddc90233e3240a3aa6bcdea8721f
treecfbf555d713619334ea8bf588e6a172095dcda7f
parenta6b41d7c52ad4b8d2fd7f2f069645401b9bbc1e9
[clang] adding explicit(bool) from c++2a

this patch adds support for the explicit bool specifier.

Changes:
- The parsing for the explicit(bool) specifier was added in ParseDecl.cpp.
- The storage of the explicit specifier was changed. the explicit specifier was stored as a boolean value in the FunctionDeclBitfields and in the DeclSpec class. now it is stored as a PointerIntPair<Expr*, 2> with a flag and a potential expression in CXXConstructorDecl, CXXDeductionGuideDecl, CXXConversionDecl and in the DeclSpec class.
- Following the AST change, Serialization, ASTMatchers, ASTComparator and ASTPrinter were adapted.
- Template instantiation was adapted to instantiate the potential expressions of the explicit(bool) specifier When instantiating their associated declaration.
- The Add*Candidate functions were adapted, they now take a Boolean indicating if the context allowing explicit constructor or conversion function and this boolean is used to remove invalid overloads that required template instantiation to be detected.
- Test for Semantic and Serialization were added.

This patch is not yet complete. I still need to check that interaction with CTAD and deduction guides is correct. and add more tests for AST operations. But I wanted first feedback.
Perhaps this patch should be spited in smaller patches, but making each patch testable as a standalone may be tricky.

Patch by Tyker

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

llvm-svn: 359949
45 files changed:
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/DeclCXX.h
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/include/clang/Basic/DiagnosticCommonKinds.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/Specifiers.h
clang/include/clang/Sema/DeclSpec.h
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/include/clang/Serialization/ASTReader.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/DeclPrinter.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/DeclSpec.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/temp/temp.deduct.guide/p1.cpp
clang/test/CXX/temp/temp.deduct.guide/p3.cpp
clang/test/PCH/cxx-explicit-specifier.cpp [new file with mode: 0644]
clang/test/SemaCXX/builtin-is-constant-evaluated.cpp
clang/test/SemaCXX/cxx2a-compat.cpp
clang/test/SemaCXX/cxx2a-explicit-bool.cpp [new file with mode: 0644]
clang/test/SemaCXX/explicit.cpp
clang/unittests/AST/Language.cpp
clang/unittests/AST/Language.h
clang/unittests/AST/MatchVerifier.h
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/www/cxx_status.html