[PATCH] D17787: [Modules] Don't swallow errors when parsing optional attributes

Davide Italiano via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 5 20:24:50 PST 2016


This revision was automatically updated to reflect the committed changes.
Closed by commit rL262789: [Modules] Don't swallow errors when parsing optional attributes. (authored by davide).

Changed prior to commit:
  http://reviews.llvm.org/D17787?vs=49575&id=49888#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D17787

Files:
  cfe/trunk/lib/Lex/ModuleMap.cpp
  cfe/trunk/test/Modules/parse-attributes.modulemap

Index: cfe/trunk/lib/Lex/ModuleMap.cpp
===================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp
+++ cfe/trunk/lib/Lex/ModuleMap.cpp
@@ -1402,7 +1402,9 @@
   
   // Parse the optional attribute list.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
+
   
   // Parse the opening brace.
   if (!Tok.is(MMToken::LBrace)) {
@@ -2067,7 +2069,9 @@
 
   // Parse the optional attributes.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
+
   if (Attrs.IsExhaustive && !ActiveModule->Parent) {
     ActiveModule->ConfigMacrosExhaustive = true;
   }
@@ -2215,7 +2219,8 @@
 
   // Parse optional attributes.
   Attributes Attrs;
-  parseOptionalAttributes(Attrs);
+  if (parseOptionalAttributes(Attrs))
+    return;
 
   if (ActiveModule) {
     // Note that we have an inferred submodule.
Index: cfe/trunk/test/Modules/parse-attributes.modulemap
===================================================================
--- cfe/trunk/test/Modules/parse-attributes.modulemap
+++ cfe/trunk/test/Modules/parse-attributes.modulemap
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t.modules
+// RUN: not %clang_cc1 -fmodules -fmodules-cache-path=%t.modules \
+// RUN:   -fmodule-map-file=%s -I%S -include "Inputs/empty.h" \
+// RUN:   -fsyntax-only -x c++ /dev/null 2>&1 | FileCheck %s
+
+// CHECK: error: expected ']' to close attribute
+// CHECK-NOT: error: expected '{' to start module 'A'
+
+module A [system {
+  header "Inputs/empty.h"
+  private header "Inputs/empty.h"
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17787.49888.patch
Type: text/x-patch
Size: 1611 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160306/deb65491/attachment.bin>


More information about the cfe-commits mailing list