https://bugs.llvm.org/show_bug.cgi?id=34420

            Bug ID: 34420
           Summary: assert in lib/Sema/SemaExpr.cpp triggers
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: d...@cubic.org
                CC: llvm-bugs@lists.llvm.org

I was running the clang-tidy program on my company's source code and it was
always triggering an assert() in lib/Sema/SemaExpr.cpp
Sema::PerformObjectMemberConversion() I have changed the assert() to return an
error status, this made clang-tidy run for me, but it is probably not the
correct solution. See the following patch:

Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp       (revision 311486)
+++ lib/Sema/SemaExpr.cpp       (working copy)
@@ -2611,7 +2611,10 @@
     // We only need to do this if the naming-class to declaring-class
     // conversion is non-trivial.
     if (!Context.hasSameUnqualifiedType(FromRecordType, URecordType)) {
-      assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
+      // doj: fails for my code
+      if (! IsDerivedFrom(FromLoc, FromRecordType, URecordType))
+        return ExprError();
+
       CXXCastPath BasePath;
       if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
                                        FromLoc, FromRange, &BasePath))

This is my first adventure with llvm and clang. How can I better fix this? The
assert is of course triggered when parsing a large and ugly source code file,
that may not be easy for me to reduce to the expression that triggers the
assert.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to