llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Alexander Kornienko (alexfh)

<details>
<summary>Changes</summary>

This commit fixes https://github.com/llvm/llvm-project/issues/140130


---
Full diff: https://github.com/llvm/llvm-project/pull/140179.diff


2 Files Affected:

- (modified) clang/include/clang/AST/PropertiesBase.td (+1-1) 
- (added) clang/test/Modules/pr140130.cpp (+33) 


``````````diff
diff --git a/clang/include/clang/AST/PropertiesBase.td 
b/clang/include/clang/AST/PropertiesBase.td
index 33336d57b6298..f3f0039ffe33e 100644
--- a/clang/include/clang/AST/PropertiesBase.td
+++ b/clang/include/clang/AST/PropertiesBase.td
@@ -414,7 +414,7 @@ let Class = PropertyTypeCase<APValue, "Union"> in {
     let Read = [{ node.getUnionValue() }];
   }
   def : Creator<[{
-    return APValue(cast<clang::FieldDecl>(fieldDecl), std::move(value));
+    return APValue(cast_if_present<clang::FieldDecl>(fieldDecl), 
std::move(value));
   }]>;
 }
 let Class = PropertyTypeCase<APValue, "AddrLabelDiff"> in {
diff --git a/clang/test/Modules/pr140130.cpp b/clang/test/Modules/pr140130.cpp
new file mode 100644
index 0000000000000..da26a005b04f8
--- /dev/null
+++ b/clang/test/Modules/pr140130.cpp
@@ -0,0 +1,33 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+// RUN: cd %t
+// RUN: %clang_cc1 -iquote . -fmodules -fno-cxx-modules -emit-module \
+// RUN:   -std=c++20 -fmodule-name=c -xc++ c.cppmap -o c.pcm
+// RUN: %clang_cc1 -iquote . -fmodules -fno-cxx-modules -emit-module \
+// RUN:   -std=c++20 -fmodule-name=a -fmodule-map-file=a.cppmap \
+// RUN:   -fmodule-file=c.pcm -xc++ a.cppmap -o a.pcm
+
+//--- a.cppmap
+module "a" {
+ header "a.h"
+}
+//--- a.h
+#include "b.h"
+//--- b.h
+#ifndef _B_H_
+#define _B_H_
+struct B {
+  consteval B() {}
+  union {
+    int a;
+  };
+};
+constexpr B b;
+#endif
+//--- c.cppmap
+module "c" {
+header "c.h"
+}
+//--- c.h
+#include "b.h"

``````````

</details>


https://github.com/llvm/llvm-project/pull/140179
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to