[llvm-branch-commits] [clang] f31e9bc - Test commit: add valid punctuation to a comment. NFC.

2020-12-16 Thread Tom Roeder via llvm-branch-commits

Author: Tom Roeder
Date: 2020-12-16T15:33:19-08:00
New Revision: f31e9bcd73eb5f99256a19ae8ed958140ba58a42

URL: 
https://github.com/llvm/llvm-project/commit/f31e9bcd73eb5f99256a19ae8ed958140ba58a42
DIFF: 
https://github.com/llvm/llvm-project/commit/f31e9bcd73eb5f99256a19ae8ed958140ba58a42.diff

LOG: Test commit: add valid punctuation to a comment. NFC.

Added: 


Modified: 
clang/lib/AST/ASTImporter.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9c0a7320e5f2..9374e9316ce8 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8223,7 +8223,7 @@ Expected ASTImporter::Import(Decl *FromD) {
   return make_error(*Error);
 }
 
-// If FromD has some updated flags after last import, apply it
+// If FromD has some updated flags after last import, apply it.
 updateFlags(FromD, ToD);
 // If we encounter a cycle during an import then we save the relevant part
 // of the import path associated to the Decl.



___
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits


[llvm-branch-commits] [clang] 1844ab7 - [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-16 Thread Tom Roeder via llvm-branch-commits

Author: Tom Roeder
Date: 2020-12-16T15:39:50-08:00
New Revision: 1844ab770cb9380a1896d83b1863b93766ffdf22

URL: 
https://github.com/llvm/llvm-project/commit/1844ab770cb9380a1896d83b1863b93766ffdf22
DIFF: 
https://github.com/llvm/llvm-project/commit/1844ab770cb9380a1896d83b1863b93766ffdf22.diff

LOG: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

This allows ASTs to be merged when they contain GenericSelectionExpr
nodes (this is _Generic from C11). This is needed, for example, for
CTU analysis of C code that makes use of _Generic, like the Linux
kernel.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter. Additionally, this change adds support for structural
equivalence of _Generic in the AST.

Reviewed By: martong, aaron.ballman

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

Added: 
clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
clang/test/ASTMerge/generic-selection-expr/Inputs/generic.cpp
clang/test/ASTMerge/generic-selection-expr/test.c
clang/test/ASTMerge/generic-selection-expr/test.cpp

Modified: 
clang/docs/LibASTMatchersReference.html
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Analysis/ExprMutationAnalyzer.cpp
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index 203840c214a2..18acfc48 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1704,6 +1704,11 @@ Node Matchers
 
 
 
+MatcherStmt>genericSelectionExprMatcherGenericSelectionExpr>...
+Matches C11 
_Generic expression.
+
+
+
 MatcherStmt>gnuNullExprMatcherGNUNullExpr>...
 Matches GNU __null 
expression.
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 0da469ea0f78..ba2dd862f171 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2362,6 +2362,10 @@ extern const internal::VariadicDynCastAllOfMatcher
 extern const internal::VariadicDynCastAllOfMatcher
 gnuNullExpr;
 
+/// Matches C11 _Generic expression.
+extern const internal::VariadicDynCastAllOfMatcher
+genericSelectionExpr;
+
 /// Matches atomic builtins.
 /// Example matches __atomic_load_n(ptr, 1)
 /// \code

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 9374e9316ce8..54816b721a4a 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -577,6 +577,7 @@ namespace clang {
 ExpectedStmt VisitVAArgExpr(VAArgExpr *E);
 ExpectedStmt VisitChooseExpr(ChooseExpr *E);
 ExpectedStmt VisitGNUNullExpr(GNUNullExpr *E);
+ExpectedStmt VisitGenericSelectionExpr(GenericSelectionExpr *E);
 ExpectedStmt VisitPredefinedExpr(PredefinedExpr *E);
 ExpectedStmt VisitDeclRefExpr(DeclRefExpr *E);
 ExpectedStmt VisitImplicitValueInitExpr(ImplicitValueInitExpr *E);
@@ -6526,6 +6527,40 @@ ExpectedStmt 
ASTNodeImporter::VisitGNUNullExpr(GNUNullExpr *E) {
   return new (Importer.getToContext()) GNUNullExpr(*TypeOrErr, *BeginLocOrErr);
 }
 
+ExpectedStmt
+ASTNodeImporter::VisitGenericSelectionExpr(GenericSelectionExpr *E) {
+  Error Err = Error::success();
+  auto ToGenericLoc = importChecked(Err, E->getGenericLoc());
+  auto *ToControllingExpr = importChecked(Err, E->getControllingExpr());
+  auto ToDefaultLoc = importChecked(Err, E->getDefaultLoc());
+  auto ToRParenLoc = importChecked(Err, E->getRParenLoc());
+  if (Err)
+return std::move(Err);
+
+  ArrayRef 
FromAssocTypes(E->getAssocTypeSourceInfos());
+  SmallVector ToAssocTypes(FromAssocTypes.size());
+  if (Error Err = ImportContainerChecked(FromAssocTypes, ToAssocTypes))
+return std::move(Err);
+
+  ArrayRef FromAssocExprs(E->getAssocExprs());
+  SmallVector ToAssocExprs(FromAssocExprs.size());
+  if (Error Err = ImportContainerChecked(FromAssocExprs, ToAssocExprs))
+return std::move(Err);
+
+  const ASTContext &ToCtx = Importer.getToContext();
+  if (E->isResultDependent()) {
+return GenericSelectionExpr::Create(
+ToCtx, ToGenericLoc, ToControllingExpr,
+llvm::makeArrayRef(ToAssocTypes), llvm::makeArrayRef(ToAssocExprs),
+ToDefaultLoc, To